
列表
毛毛苦练吉吉国王
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leetcode刷题15.三数之和
1.题目2.题目意思在列表中找出三个和为0的数,返回他们。3.代码我的超时代码:class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: nums.sort() ans = [] n = len(nums) for i in range(n-2): for j in range(i+1, n-1):原创 2020-05-18 15:11:43 · 161 阅读 · 0 评论 -
leetcode20200423每日一题-面试题56 - I. 数组中数字出现的次数
1.题目2.题目意思数组中的数字都是成对的,有两个数除外。找出这两个。另外注意时间复杂度O(n),空间复杂度O(1)。太苛刻了!3.代码class Solution: def singleNumbers(self, nums: List[int]) -> List[int]: ret, index = 0, 0 # step1 找出两个数做异...原创 2020-04-28 14:45:53 · 146 阅读 · 0 评论 -
leetcode20200423每日一题-(15)46.全排列
1.题目2.题目意思排列组合嘛~3.代码解法1:class Solution: def permute(self, nums: List[int]) -> List[List[int]]: return list(itertools.permutations(nums))思路:python函数君子生非异也,善假于物也。itertools.permu...原创 2020-04-25 09:57:30 · 148 阅读 · 0 评论 -
leetcode20200424每日一题-面试题51.数组中的逆序对
1.题目2.题目意思计算逆序对的总数。3.代码class Solution: def reversePairs(self, nums: List[int]) -> int: q = [] res = 0 for v in nums: i = bisect.bisect_left(q,-v) ...原创 2020-04-24 12:27:48 · 242 阅读 · 0 评论 -
leetcode20200418每日一题-11.盛最多水的容器
1.题目2.题目意思如图所示,给定一个列表,列表里每个数作为一个柱子,找出两个柱子,使得接的水最多。3.代码class Solution: def maxArea(self, height: List[int]) -> int: res=0 i=0 j=len(height)-1 while i<j: ...原创 2020-04-18 11:04:00 · 186 阅读 · 0 评论 -
leetcode20200417每日一题-55.跳跃游戏
1.题目2.题目意思就是能不能到最后一格。简单分析,除了最后一个数,其他数要是不等于0就一定可以到;如果中间有0,只要前面有数能跨过去,就也行。3.代码解法1:class Solution: def canJump(self, nums: List[int]) -> bool: start = 0 end = 0 n = l...原创 2020-04-17 13:32:53 · 227 阅读 · 0 评论