摘要: class Solution: def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': if not root or root==p or root==q:return 阅读全文
posted @ 2021-03-28 20:21 小千北同学超爱写代码 阅读(46) 评论(0) 推荐(0) 编辑
摘要: class Solution: def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': if p.val<root.val and q.val<root.val: re 阅读全文
posted @ 2021-03-28 20:08 小千北同学超爱写代码 阅读(36) 评论(0) 推荐(0) 编辑
摘要: from typing import Set, Tuple class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: nums = sorted(nums) res = [] prev = None for i, 阅读全文
posted @ 2021-03-28 18:51 小千北同学超爱写代码 阅读(45) 评论(0) 推荐(0) 编辑
摘要: class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: d={} for i ,x in enumerate(nums): another_num=target-x if another_num in 阅读全文
posted @ 2021-03-28 18:21 小千北同学超爱写代码 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 给你一个整数数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口内的 k 个数字。滑动窗口每次只向右移动一位。 返回滑动窗口中的最大值。 来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/slidin 阅读全文
posted @ 2021-03-28 17:45 小千北同学超爱写代码 阅读(78) 评论(0) 推荐(0) 编辑