
leetcode
逆着风走
这个作者很懒,什么都没留下…
展开
-
leetcode python Minimum Path Sum
动态规划题目,创建一个与grid一样大小的G,G里面存储到达每个点的最小距离,然后把G的所有点填满,最后右下角的值既是结果。class Solution(object): def minPathSum(self, grid): """ :type grid: List[List[int]] :rtype: int """...原创 2018-07-27 09:27:29 · 204 阅读 · 0 评论 -
Permutation Sequence python
解题的窍门是,每一位数字可以用,K对该数字后面所有数字的组合数量相除取整确定。class Solution: def getPermutation(self, n, k): """ :type n: int :type k: int :rtype: str """ jc=[] ...原创 2018-08-10 09:47:26 · 278 阅读 · 0 评论 -
leetcode python Plus One
题目有两个坑,一个是进位的判断,可以按照digits[i] !=9,也可以digits[i] +1=10.另一个是首位需要进位时的判断,这时要解决怎么让计算机知道数据是99999,即全部有进位。容易想到的是设置一个flag,也可以想下面代码增加一个输出。但是一个输出更加符合编码规范。class Solution: def plusOne(self, digits): ...原创 2018-08-07 09:24:27 · 272 阅读 · 0 评论