上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 47 下一页
摘要: 题目描述: 方法: class Solution: def computeArea(self, A: int, B: int, C: int, D: int, E: int, F: int, G: int, H: int) -> int: # 调整两个矩形位置, 让第一个矩形靠最左边 if A > 阅读全文
posted @ 2019-10-04 18:25 oldby 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:O(N) class Solution: def countNodes(self, root: TreeNode) -> int: if not root: return 0 return 1 + self.countNodes(root.left) + self.countNo 阅读全文
posted @ 2019-10-04 17:11 oldby 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:动态规划 class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: if not matrix: return 0 row = len(matrix) col = len(matrix[0]) 阅读全文
posted @ 2019-10-04 16:16 oldby 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:二叉搜索树+滑动窗口 方法二:桶排序 O(N) class Solution: def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool: from collections i 阅读全文
posted @ 2019-10-04 13:40 oldby 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交:超时 class Solution: def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool: for i in range(len(nums)-1): for j in range(i+1,min 阅读全文
posted @ 2019-10-04 10:40 oldby 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交: class Solution: def containsDuplicate(self, nums: List[int]) -> bool: nums2 = set(nums) return not len(nums2)==len(nums) 方法二:哈希表 class So 阅读全文
posted @ 2019-10-04 09:46 oldby 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:回溯 class Solution: def combinationSum3(self, k: int, n: int) -> List[List[int]]: res = [] def helper(k,n,start,tmp): if k==0: if n==0: res.a 阅读全文
posted @ 2019-10-03 17:00 oldby 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:堆排序* class Solution: def findKthLargest(self, nums: List[int], k: int) -> int: def adjust_heap(idx, max_len): left = 2 * idx + 1 right = 2 * 阅读全文
posted @ 2019-10-03 16:20 oldby 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交: class Solution: def findOrder(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]: indegree = [0 for _ in range(numCourse 阅读全文
posted @ 2019-10-03 16:04 oldby 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:双指针 O(N) class Solution: def minSubArrayLen(self, s: int, nums: List[int]) -> int: left = 0 res = float('inf') sum = 0 for i in range(len(nu 阅读全文
posted @ 2019-10-03 11:17 oldby 阅读(122) 评论(0) 推荐(0) 编辑
上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 47 下一页