File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
2
Given string a and b, with b containing all distinct characters,
3
- find the longest common subsequence's
3
+ find the longest common subsequence's
4
4
5
5
length. Expected complexity O(nlogn).
6
6
"""
7
7
8
8
9
- def maxCommonSubString ( S1 , S2 ):
10
- ## Assuming S2 has all unique chars
11
- S2Dic = {S2 [i ]:i for i in xrange (len (S2 ))}
12
- maxR = 0
13
- subS = ''
9
+ def max_common_sub_string ( s1 , s2 ):
10
+ # Assuming s2 has all unique chars
11
+ s2dic = {s2 [i ]: i for i in xrange (len (s2 ))}
12
+ maxr = 0
13
+ subs = ''
14
14
i = 0
15
- while i < len (S1 ):
16
- if S1 [i ] in S2Dic :
17
- j = S2Dic [ S1 [i ]]
15
+ while i < len (s1 ):
16
+ if s1 [i ] in s2dic :
17
+ j = s2dic [ s1 [i ]]
18
18
k = i
19
- while j < len (S2 ) and k < len (S1 ) and S1 [k ] == S2 [j ]:
19
+ while j < len (s2 ) and k < len (s1 ) and s1 [k ] == s2 [j ]:
20
20
k += 1
21
21
j += 1
22
- if k - i > maxR :
23
- maxR = k - i
24
- subS = S1 [i :k ]
22
+ if k - i > maxr :
23
+ maxr = k - i
24
+ subs = s1 [i :k ]
25
25
i = k
26
26
else :
27
27
i += 1
28
- return subS
28
+ return subs
Original file line number Diff line number Diff line change 5
5
the character '.'.
6
6
"""
7
7
8
- def isValidSudoku (self , board ):
8
+ def is_valid_sudoku (self , board ):
9
9
seen = []
10
10
for i , row in enumerate (board ):
11
11
for j , c in enumerate (row ):
You can’t perform that action at this time.
0 commit comments