Iam_Sandeep

Untitled

Jun 16th, 2022
1,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. #User function Template for python3
  2. from collections import OrderedDict as od
  3. def uniqueRow(row, col, mat):
  4.     def add(word):
  5.         cur=root
  6.         for w in word:
  7.             cur=cur.setdefault(w,od())
  8.         cur['$']=True
  9.     ans=[]
  10.     def find(cur,t):
  11.         for w in cur.keys():
  12.             if w=='$':
  13.                 ans.append(t)
  14.             else:
  15.                 find(cur[w],t+[w])
  16.     root=od()
  17.     t=0
  18.     for i in range(row):
  19.         add(mat[t:t+col])
  20.         t=t+col
  21.        
  22.     find(root,[])
  23.     return ans
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment