diff --git "a/1.\344\270\244\346\225\260\344\271\213\345\222\214.py" "b/1.\344\270\244\346\225\260\344\271\213\345\222\214.py" index 6c96331..d169d1b 100644 --- "a/1.\344\270\244\346\225\260\344\271\213\345\222\214.py" +++ "b/1.\344\270\244\346\225\260\344\271\213\345\222\214.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: hash-table +# Tips: array, hash-table class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: diff --git "a/11.\347\233\233\346\234\200\345\244\232\346\260\264\347\232\204\345\256\271\345\231\250.py" "b/11.\347\233\233\346\234\200\345\244\232\346\260\264\347\232\204\345\256\271\345\231\250.py" index 9b35621..6de7ff9 100644 --- "a/11.\347\233\233\346\234\200\345\244\232\346\260\264\347\232\204\345\256\271\345\231\250.py" +++ "b/11.\347\233\233\346\234\200\345\244\232\346\260\264\347\232\204\345\256\271\345\231\250.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: two-pointers +# Tips: array, two-pointers class Solution: def maxArea(self, height: List[int]) -> int: diff --git "a/15.\344\270\211\346\225\260\344\271\213\345\222\214.py" "b/15.\344\270\211\346\225\260\344\271\213\345\222\214.py" index b88b135..18d6c97 100644 --- "a/15.\344\270\211\346\225\260\344\271\213\345\222\214.py" +++ "b/15.\344\270\211\346\225\260\344\271\213\345\222\214.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: sort, two-pointers +# Tips: array, sort, two-pointers class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: diff --git "a/17.\347\224\265\350\257\235\345\217\267\347\240\201\347\232\204\345\255\227\346\257\215\347\273\204\345\220\210.py" "b/17.\347\224\265\350\257\235\345\217\267\347\240\201\347\232\204\345\255\227\346\257\215\347\273\204\345\220\210.py" index 4f4476c..ade4f66 100644 --- "a/17.\347\224\265\350\257\235\345\217\267\347\240\201\347\232\204\345\255\227\346\257\215\347\273\204\345\220\210.py" +++ "b/17.\347\224\265\350\257\235\345\217\267\347\240\201\347\232\204\345\255\227\346\257\215\347\273\204\345\220\210.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: backtracking +# Tips: string, backtracking class Solution: def letterCombinations(self, digits: str) -> List[str]: diff --git "a/19.\345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254n\344\270\252\350\212\202\347\202\271.py" "b/19.\345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254n\344\270\252\350\212\202\347\202\271.py" index 6f2618e..e73e728 100644 --- "a/19.\345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254n\344\270\252\350\212\202\347\202\271.py" +++ "b/19.\345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254n\344\270\252\350\212\202\347\202\271.py" @@ -11,7 +11,7 @@ # self.val = val # self.next = next -# Tips: linked-list +# Tips: linked-list, two-pointers class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: diff --git "a/2.\344\270\244\346\225\260\347\233\270\345\212\240.py" "b/2.\344\270\244\346\225\260\347\233\270\345\212\240.py" index c108f47..585e706 100644 --- "a/2.\344\270\244\346\225\260\347\233\270\345\212\240.py" +++ "b/2.\344\270\244\346\225\260\347\233\270\345\212\240.py" @@ -11,7 +11,7 @@ # self.val = val # self.next = next -# Tips: linked-list +# Tips: linked-list, math class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: @@ -36,7 +36,6 @@ def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: for i in range(1, len(result)): node_tmp.next = ListNode(result[i]) node_tmp = node_tmp.next - return result_node # @lc code=end diff --git "a/20.\346\234\211\346\225\210\347\232\204\346\213\254\345\217\267.py" "b/20.\346\234\211\346\225\210\347\232\204\346\213\254\345\217\267.py" index 364b6a0..2785670 100644 --- "a/20.\346\234\211\346\225\210\347\232\204\346\213\254\345\217\267.py" +++ "b/20.\346\234\211\346\225\210\347\232\204\346\213\254\345\217\267.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: stack +# Tips: string, stack class Solution: def isValid(self, s: str) -> bool: diff --git "a/22.\346\213\254\345\217\267\347\224\237\346\210\220.py" "b/22.\346\213\254\345\217\267\347\224\237\346\210\220.py" index cb24ebb..c7884a4 100644 --- "a/22.\346\213\254\345\217\267\347\224\237\346\210\220.py" +++ "b/22.\346\213\254\345\217\267\347\224\237\346\210\220.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: backtracking +# Tips: string, backtracking class Solution: def generateParenthesis(self, n: int): diff --git "a/3.\346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.py" "b/3.\346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.py" index bae9726..cc70519 100644 --- "a/3.\346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.py" +++ "b/3.\346\227\240\351\207\215\345\244\215\345\255\227\347\254\246\347\232\204\346\234\200\351\225\277\345\255\220\344\270\262.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: sliding-window, two-pointers +# Tips: string, sliding-window, two-pointers, hash-table class Solution: def lengthOfLongestSubstring(self, s: str) -> int: diff --git "a/33.\346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204.py" "b/33.\346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204.py" index 550209f..66de55a 100644 --- "a/33.\346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204.py" +++ "b/33.\346\220\234\347\264\242\346\227\213\350\275\254\346\216\222\345\272\217\346\225\260\347\273\204.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: binary-search +# Tips: array, binary-search class Solution: def search(self, nums, target: int) -> int: diff --git "a/34.\345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\345\205\203\347\264\240\347\232\204\347\254\254\344\270\200\344\270\252\345\222\214\346\234\200\345\220\216\344\270\200\344\270\252\344\275\215\347\275\256.py" "b/34.\345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\345\205\203\347\264\240\347\232\204\347\254\254\344\270\200\344\270\252\345\222\214\346\234\200\345\220\216\344\270\200\344\270\252\344\275\215\347\275\256.py" index 1686afd..27679d4 100644 --- "a/34.\345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\345\205\203\347\264\240\347\232\204\347\254\254\344\270\200\344\270\252\345\222\214\346\234\200\345\220\216\344\270\200\344\270\252\344\275\215\347\275\256.py" +++ "b/34.\345\234\250\346\216\222\345\272\217\346\225\260\347\273\204\344\270\255\346\237\245\346\211\276\345\205\203\347\264\240\347\232\204\347\254\254\344\270\200\344\270\252\345\222\214\346\234\200\345\220\216\344\270\200\344\270\252\344\275\215\347\275\256.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: binary-search +# Tips: array, binary-search class Solution: def searchRange(self, nums, target: int): diff --git "a/39.\347\273\204\345\220\210\346\200\273\345\222\214.py" "b/39.\347\273\204\345\220\210\346\200\273\345\222\214.py" index 0fffc80..abc76bd 100644 --- "a/39.\347\273\204\345\220\210\346\200\273\345\222\214.py" +++ "b/39.\347\273\204\345\220\210\346\200\273\345\222\214.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: backtracking +# Tips: array, backtracking class Solution: def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: diff --git "a/49.\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215\345\210\206\347\273\204.py" "b/49.\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215\345\210\206\347\273\204.py" index 4bed2d2..85b2cab 100644 --- "a/49.\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215\345\210\206\347\273\204.py" +++ "b/49.\345\255\227\346\257\215\345\274\202\344\275\215\350\257\215\345\210\206\347\273\204.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: hash-table +# Tips: string, hash-table class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: diff --git "a/5.\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262.py" "b/5.\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262.py" index 2054038..9584cee 100644 --- "a/5.\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262.py" +++ "b/5.\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262.py" @@ -6,7 +6,7 @@ # @lc code=start -# Tips: two-pointers +# Tips: string, dynamic-programming class Solution: def get_expand_start_end(self, s, left, right): diff --git "a/55.\350\267\263\350\267\203\346\270\270\346\210\217.py" "b/55.\350\267\263\350\267\203\346\270\270\346\210\217.py" new file mode 100644 index 0000000..87647c3 --- /dev/null +++ "b/55.\350\267\263\350\267\203\346\270\270\346\210\217.py" @@ -0,0 +1,27 @@ +# +# @lc app=leetcode.cn id=55 lang=python3 +# +# [55] 跳跃游戏 +# + +# @lc code=start + +# Tips: array, greedy + +class Solution: + def canJump(self, nums: List[int]) -> bool: + # 代表从当前 0 开始可以走的最远距离 + far = 0 + length = len(nums) + for i in range(0, length): + if i > far: + # 如果当前位置比最远可以走的距离远,返回 False + return False + if i + nums[i] > far: + # 更新可以走的最远距离 + far = i + nums[i] + + return True + +# @lc code=end +