Skip to content

Commit

Permalink
add new
Browse files Browse the repository at this point in the history
  • Loading branch information
yxudong committed Oct 27, 2020
1 parent d164d8b commit 735c793
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 15 deletions.
2 changes: 1 addition & 1 deletion 1.两数之和.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion 11.盛最多水的容器.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# @lc code=start

# Tips: two-pointers
# Tips: array, two-pointers

class Solution:
def maxArea(self, height: List[int]) -> int:
Expand Down
2 changes: 1 addition & 1 deletion 15.三数之和.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down
2 changes: 1 addition & 1 deletion 17.电话号码的字母组合.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# @lc code=start

# Tips: backtracking
# Tips: string, backtracking

class Solution:
def letterCombinations(self, digits: str) -> List[str]:
Expand Down
2 changes: 1 addition & 1 deletion 19.删除链表的倒数第n个节点.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions 2.两数相加.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 20.有效的括号.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# @lc code=start

# Tips: stack
# Tips: string, stack

class Solution:
def isValid(self, s: str) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion 22.括号生成.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# @lc code=start

# Tips: backtracking
# Tips: string, backtracking

class Solution:
def generateParenthesis(self, n: int):
Expand Down
2 changes: 1 addition & 1 deletion 3.无重复字符的最长子串.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion 33.搜索旋转排序数组.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# @lc code=start

# Tips: binary-search
# Tips: array, binary-search

class Solution:
def search(self, nums, target: int) -> int:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# @lc code=start

# Tips: binary-search
# Tips: array, binary-search

class Solution:
def searchRange(self, nums, target: int):
Expand Down
2 changes: 1 addition & 1 deletion 39.组合总和.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down
2 changes: 1 addition & 1 deletion 49.字母异位词分组.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down
2 changes: 1 addition & 1 deletion 5.最长回文子串.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
27 changes: 27 additions & 0 deletions 55.跳跃游戏.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 735c793

Please sign in to comment.