加载中
LeetCode.46 | 全排列

""" https://leetcode-cn.com/problems/permutations/solution/di-gui-hui-su-xuan-shu-fa-yu-jiao-huan-fa-by-user5/ https://leetcode-cn.com/problems/permutations/solution/hot-100-46q...

10/06 20:00
81
LeetCode.45 | 跳跃游戏 II

""" https://leetcode-cn.com/problems/jump-game-ii/solution/tiao-yue-you-xi-ii-by-leetcode-solution/ 思路:这是一个典型的贪婪算法:从局部优先->全局优先 1.遍历数组从0~n-1(不需要访问...

09/10 16:02
1
LeetCode 44 | 通配符匹配

好久没写了,连最简单的DP都不太会了;看了好久的题解,最后把例子画出来才算正式完成. ''' https://leetcode-cn.com/problems/wildcard-matching/solution/tong-pei-fu-pi-pei-by-leetcode-so...

09/04 16:30
0
LeetCode 43 | 字符串相乘

''' 这个题目和<零基础学算法>中计算阶乘相类似 思路:将较长数字的值与另一个数字中值相乘,将结果保存入对应数组,并进位 1.1 比较两个数值,总是将较小的值n1与较大值中n2的每一位相乘dig 1.2...

07/26 09:02
93
LeetCode 42 | 接雨水

''' https://leetcode-cn.com/problems/trapping-rain-water/solution/wei-en-tu-jie-fa-zui-jian-dan-yi-dong-10xing-jie-j/ 数学法(韦恩)思路:其核心是S_left+S_right-S_matrix-S_column ...

07/09 14:32
23
LeetCode.41 | 缺失的第一个正数

''' 我只想到用python的in进行,Hash表看题解才明白 https://leetcode-cn.com/problems/first-missing-positive/solution/tong-pai-xu-python-dai-ma-by-liweiwei1419/ In思路:比较简单,就用p...

07/01 13:50
41
LeetCode 40 | 组合总和 II

''' 思路:参见39题方法.增加去重复 1.1:数组去重if cur>begin and candidates[cur-1]==candidates[cur] ''' class Solution: def combinationSum2(self,candidates,target): #排序 ......

06/12 14:52
41
LeetCode 39 | 组合总和

''' backtrack:https://leetcode-cn.com/problems/combination-sum/solution/chao-qiang-gifzhu-ni-shi-yong-dong-tai-gui-hua-qiu/ bt思路:这题是比较典型的回溯算法,递归+剪枝进行加快速度...

06/12 14:51
29
LeetCode 38 | 外观数列

''' https://leetcode-cn.com/problems/count-and-say/solution/ji-su-jie-bu-di-gui-zhi-ji-lu-qian-hou-liang-ren-p/ 思路:这题难在不太好理解题意,其本质有点像letter从1->2进位+当前数字...

06/01 16:46
38
LeetCode 37 | 解数独

""" https://leetcode-cn.com/problems/sudoku-solver/solution/hui-su-fa-jie-shu-du-by-i_use_python/ https://leetcode-cn.com/problems/sudoku-solver/solution/zi-cong-wo-xue-hui-liao...

05/30 19:56
100
LeetCode 36 | 有效的数独

""" https://leetcode-cn.com/problems/valid-sudoku/solution/you-xiao-de-shu-du-by-leetcode/ 思路: 此题困难点在于计算3x3的位置坐标 row//3*3+column//3 计算处于哪个3x3矩阵中 1.初始化...

05/21 15:26
37
LeetCode 35 | 搜索插入位置

""" 思路:此题比较简单,就是顺序查找 1.循环列表,初始化下标i和对应当前值cur 2.循环nums,并且target<=current;更新返回值 3.最后返回当前下标i,即为求解值 注意:相同值插在前面位置,所以cur...

05/20 12:05
16
LeetCode 34 | 在排序数组中查找元素的第一个和最后一个位置

""" https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/solution/er-fen-cha-zhao-suan-fa-xi-jie-xiang-jie-by-labula/ 思路:将nums分成左右两个...

05/19 15:47
17
LeetCode.33 | 搜索旋转排序数组

""" https://leetcode-cn.com/problems/search-in-rotated-sorted-array/solution/pythonjs-er-fen-fa-33-sou-suo-xuan-zhuan-pai-xu-sh/ 思路:二分法,先判断有序域;再判断目标值在哪个列表域...

05/18 16:36
14
LeetCode.32 | 最长有效括号

""" https://leetcode-cn.com/problems/longest-valid-parentheses/solution/zhan-he-dong-tai-gui-hua-liang-chong-jie-fa-by-ree/ https://leetcode-cn.com/problems/longest-valid-parent...

05/14 20:18
33
LeetCode.31 | 下一个排列

""" https://leetcode-cn.com/problems/next-permutation/solution/xia-yi-ge-pai-lie-by-leetcode/ https://leetcode-cn.com/problems/next-permutation/solution/ti-yi-zhuan-hua-zhao-zui...

04/21 15:37
33
LeetCode.30 | 串联所有单词的子串

""" https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words/solution/30-chuan-lian-suo-you-dan-ci-de-zi-chuan-by-bu-jue/ 思路:此题较难,关键是给定字符串是不考虑...

04/17 14:01
41
LeetCode.29 | 两数相除

""" https://leetcode-cn.com/problems/divide-two-integers/solution/chu-fa-dao-jian-fa-de-zhuan-hua-by-h_n/ 思路:此题比较困难,涉及了位移'<<'操作,位移实际就是2**n次方操作 先写出带有...

04/16 14:41
52
LeetCode.28 | 实现 strStr()

""" 思路:利用滑动窗口,从左向右按needle的长度进行滑动;是否当前字符串current=needle 1.定义指针i,当前字符串current 2.1如果current=needle;返回当前i 2.2如果循结束,未找到匹配值,返回-...

04/15 14:21
61
LeetCode.27|移除元素

""" https://leetcode-cn.com/problems/remove-element/solution/hua-jie-suan-fa-27-yi-chu-yuan-su-by-guanpengchn/ 思路:将数据分成left,right;left区域为未检查区,right为等值区 1.定义l...

04/15 13:52
43

没有更多内容

加载失败,请刷新页面

返回顶部
顶部