上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 47 下一页
摘要: 题目描述: 第一次提交:O(N) class Solution: def findMin(self, nums: List[int]) -> int: if not nums: return l,r = 0,len(nums)-1 while l<r: if nums[l]>nums[r]: l + 阅读全文
posted @ 2019-07-17 20:42 oldby 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:动态规划 class Solution: def maxProduct(self, nums: List[int]) -> int: ret,up,down=nums[0],nums[0],nums[0] for n in nums[1:]: if n>=0: up,down=m 阅读全文
posted @ 2019-07-17 20:22 oldby 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一: return " ".join(s.split()[::-1]) 方法二: class Solution: def reverseWords(self, s: str) -> str: res = re.findall('\S+',s) return " ".join(res[ 阅读全文
posted @ 2019-07-17 19:47 oldby 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一: class Solution: def evalRPN(self, t: List[str]) -> int: d=[] n=len(t) for i in range(n): if '0'<=t[i][-1]<='9': d+=[t[i]] else: d[-2]=str(i 阅读全文
posted @ 2019-07-17 18:07 oldby 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:快排 class Solution: def sortList(self, head: ListNode) -> ListNode: def partition(start, end): node = start.next.next pivotPrev = start.next 阅读全文
posted @ 2019-07-17 17:13 oldby 阅读(393) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一: # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def inser 阅读全文
posted @ 2019-07-17 16:03 oldby 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:有序字典 O(1) from collections import OrderedDict class LRUCache(OrderedDict): def __init__(self, capacity: int): self.capacity = capacity def g 阅读全文
posted @ 2019-07-17 14:42 oldby 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 恢复内容开始 题目描述: 方法一:层次遍历 """ # Definition for a Node. class Node: def __init__(self, val, left, right, next): self.val = val self.left = left self.right 阅读全文
posted @ 2019-07-17 13:31 oldby 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一: class Solution(object): def reorderList(self, head): """ :type head: ListNode :rtype: None Do not return anything, modify head in-place ins 阅读全文
posted @ 2019-07-17 11:47 oldby 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:O(n) O(n) # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class So 阅读全文
posted @ 2019-07-17 10:51 oldby 阅读(140) 评论(0) 推荐(0) 编辑
上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 47 下一页