Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #User function Template for python3
- from collections import OrderedDict as od
- def uniqueRow(row, col, mat):
- def add(word):
- cur=root
- for w in word:
- cur=cur.setdefault(w,od())
- cur['$']=True
- ans=[]
- def find(cur,t):
- for w in cur.keys():
- if w=='$':
- ans.append(t)
- else:
- find(cur[w],t+[w])
- root=od()
- t=0
- for i in range(row):
- add(mat[t:t+col])
- t=t+col
- find(root,[])
- return ans
Advertisement
Add Comment
Please, Sign In to add comment