上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 30 下一页
摘要: 思路: 深度遍历 1.第一层main函数里 两层循环找 grid[x][y] == '1' 的点 res += 1 2.递归函数里,把与该点四个方向相邻的,值为‘1’的点全部标0 标0方法: 对坐标(x,y)四个方向中 值 == ‘1’ 的赋0 再递归。 注意: 1. 对于二维数组,判空要用 if 阅读全文
posted @ 2020-05-13 13:22 ChevisZhang 阅读(178) 评论(0) 推荐(0) 编辑
摘要: https://www.cnblogs.com/jpfss/p/10973806.html 阅读全文
posted @ 2020-05-11 16:06 ChevisZhang 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 感谢大神的资源: https://blog.csdn.net/qq1773304209/article/details/105856782 解压之后的详细步骤: https://www.cnblogs.com/ljxh/p/11222898.html 我也是一个资源整合者了 lmao 阅读全文
posted @ 2020-05-11 15:46 ChevisZhang 阅读(7918) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/find-the-duplicate-number/ 简单思路: 1. return sum( nums ) - n*(n+1)/2 2. set() if num in set: return num 用set 3. nums.so 阅读全文
posted @ 2020-05-07 21:21 ChevisZhang 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 本题为leetcode 207 210题 思路: 1.本题求课程学习路径,即 9021 -> 9024 -> 9417 这种顺序 2.观察可知 课程学习路劲为有向图, 如果无环则可输出,有环则返回False 方法: 1. 遍历所有二元对,确定0 - n-1门课程的入度 2. 顺便将所有课程的进阶课程 阅读全文
posted @ 2020-05-07 15:47 ChevisZhang 阅读(303) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/u011058765/article/details/51435502 https://blog.csdn.net/yibo492387/article/details/81875436 找了好久 看了这篇之后就懂了。 阅读全文
posted @ 2020-04-25 16:47 ChevisZhang 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 思路: 1.计算机中的数上界是 2^32,其中3的幂值中最大值是 3^19 2.判断 3^19 %n == 0 and n>0 class Solution: def isPowerOfThree(self, n: int) -> bool: return n>0 and 1162261467%n  阅读全文
posted @ 2020-04-18 15:21 ChevisZhang 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 思路: 来自https://leetcode-cn.com/problems/palindrome-linked-list/solution/zhong-dian-fan-zhuan-dui-bi-by-powcai/ 例: 1->2->3->2->1 1.先用双指针找到中点上界。 即:找到第四个节 阅读全文
posted @ 2020-04-17 18:00 ChevisZhang 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 想法: 本题作为9024数据结构与算法的一道经典题,计算质数,用的方法''厄拉多塞筛法''需要经常温习 代码: class Solution: def countPrimes(self, n: int) -> int: if n<=2: return 0 dp = [1 for _ in range 阅读全文
posted @ 2020-04-17 10:43 ChevisZhang 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 进制转换函数: 1. bin(),oct(),hex() 分别是用来将十进制的数字Interger 转化成 二进制string(‘0b1000’),八进制string('0o10'),十六进制string('0x8')。 2. int(n,2),int(n,8),int(n,16) 可以将2,8,1 阅读全文
posted @ 2020-04-16 17:48 ChevisZhang 阅读(392) 评论(0) 推荐(0) 编辑
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 30 下一页