
Algorithm_leetCode
Algorithm_leetCode
七七 ...
这个作者很懒,什么都没留下…
展开
-
9. 回文数(twoSum)
9. 回文数(twoSum)1. pythonclass Solution: def isPalindrome(self, x: int) -> bool: if x<0 or (x!=0 and x%10==0): return False reversedNumber=0 while x>reversedNumber: reversedNumber = reversedNumbe原创 2021-03-05 20:48:39 · 69 阅读 · 0 评论 -
946. 验证栈序列(validateStackSequences)
946. 验证栈序列(validateStackSequences)1. pythonclass Solution: def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool: stack,i=[],0 for num in pushed: stack.append(num) while stack and st原创 2021-01-09 18:44:16 · 143 阅读 · 0 评论 -
31. 栈的压入、弹出序列(validateStackSequences)
31. 栈的压入、弹出序列(validateStackSequences)1. pythonclass Solution: def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool: stack,i =[],0 for num in pushed: stack.append(num) while stack an原创 2021-01-09 18:42:25 · 115 阅读 · 0 评论 -
54. 螺旋矩阵(spiralOrder)
54. 螺旋矩阵(spiralOrder)1. pythonclass Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: if not matrix:return [] left,top=0,0 right,bottom=len(matrix[0]),len(matrix) ans=[] while left<ri原创 2021-01-09 15:04:27 · 399 阅读 · 0 评论 -
3.无重复最长字串(lengthOfLongestSubstring)
3. 无重复最长字串(lengthOfLongestSubstring)1. pythonclass Solution: def lengthOfLongestSubstring(self, s: str) -> int: if not s: return 0 cur_len,max_len=0,0 s_len = len(s) left = 0 hashSet = set()原创 2021-01-08 16:59:09 · 445 阅读 · 0 评论 -
2. 两数相加addTwoNumbers
2. 两数相加addTwoNumbers(twoSum)1. pythonclass Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: carry = 0 pre=ListNode(0); cur=pre while(l1 or l2): x=0 if l1==None else l1.val原创 2021-01-08 13:43:01 · 102 阅读 · 0 评论 -
1. 两数之和(twoSum)
1. 两数之和(twoSum)1. pythonclass Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: # nums_length = len(nums) # for i in range(nums_length): # for j in range(i+1,nums_length): # if targe原创 2021-01-07 20:51:23 · 127 阅读 · 0 评论