西维蜀黍的OJ Blog

🐒 Software engineer | 📷 Photographer | 👹 Urban explorer

[Notes] Trees - Tries(Prefix Tree,前缀树)

  ...


[Notes] Linked List

  ...


[Notes] Greedy

  ...


[Notes] Hashmap

  ...


[Python] Basic Python Knowledge for Leetcode

For xs = [8, 23, 45] for x in xs: print("item #{} = {}".format(index, x)) Use the built-in function enumerate(): for idx, x in enumerate(xs): print(idx, x) Data structure List l = [] # or l = list() # add l.append(1) print(l) # 1 # for loop >>> for i, value in enumerate(['A', 'B', 'C']): ... print(i, value) ... 0 A 1 B 2 C Ref https://swsmile.info/post/python-collection-list/ Map/Dict # init thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(type(thisdict)) # init 2 thisdict = dict(name = "John", age = 36, country = "Norway") print(thisdict) # delete del tel['sape'] # dict -> list >>> tel {'jack': 4098, 'guido': 4127, 'irv': 4127} >>> list(tel) ['jack', 'guido', 'irv'] # get >>> 'Thomas' in d False # for-loop >>> d = {'a': 1, 'b': 2, 'c': 3} >>> for key in d: .   ...