1- class Node (object ):
21
3- def __init__ (self , val ):
4- self .val = val
2+ import sys , string
3+ # class Solution:
4+ # def coinChange(self, nums, target):
5+ # resp =[0] * (target+1)
6+ # for i in range(1, target+1):
7+ # cur = sys.maxsize
8+ # for each in nums:
9+ # if i - each >= 0:
10+ # cur = min(resp[i-each]+1, cur)
11+ # resp[i] = cur
12+ # return resp[target] if resp[target] != sys.maxsize else -1
513
6- def __getitem__ (self , k ):
7- return getattr (self , k )
14+ # print(Solution().coinChange([2],3))
815
9- a = Node ('ac' )
10- print (a ["val" ])
11- print (a .val )
16+
17+ def test (a , b ):
18+ choice = dict (zip ('0123456789' + string .ascii_lowercase , range (36 )))
19+ choice2 = dict (zip (range (36 ), '0123456789' + string .ascii_lowercase ))
20+ len_a , len_b = len (a ), len (b )
21+ lens = len_a + 1 if len_a > len_b else len_b + 1
22+ resp = [0 ] * lens
23+ flag = False
24+ for i in range (lens ):
25+ if len_a - i > 0 :
26+ resp [i ] += choice [a [len_a - i - 1 ]]
27+ if len_b - i > 0 :
28+ resp [i ] += choice [b [len_b - i - 1 ]]
29+ if flag :
30+ resp [i ] += 1
31+ if resp [i ] > 35 :
32+ resp [i ] -= 35
33+ flag = True
34+ else :
35+ flag = False
36+ resp [i ] = choice2 [resp [i ]]
37+ return '' .join (resp )
38+
39+ # print(test('abc', 'adb'))
40+
41+ def test (s ):
42+ if not s :
43+ return 0
44+ i , resp , mapping = 0 , 0 , {}
45+ for j in range (len (s )):
46+ word = s [j ]
47+ if word in mapping and mapping [word ] >= i :
48+ resp = max (j - i , resp )
49+ i = mapping [word ] + 1
50+ mapping [word ] = j
51+ return max (resp , j - i + 1 )
52+
53+ print (test ('abca' ))
0 commit comments