04 2020 档案

摘要:https://blog.csdn.net/u011058765/article/details/51435502 https://blog.csdn.net/yibo492387/article/details/81875436 找了好久 看了这篇之后就懂了。 阅读全文
posted @ 2020-04-25 16:47 ChevisZhang 阅读(116) 评论(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 阅读(93) 评论(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 阅读(137) 评论(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 阅读(127) 评论(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 阅读(420) 评论(0) 推荐(0)
摘要:本题思路:三次旋转 1. 1234567 -》 7654321 经过第一次旋转可把后3位数转到前面 2. 7654321 -》 5674321 3. 5674321 -》5671234 其他思路: 1.nums[ : ] = nums[ k: ] + nums[ :k ] 切片 2. for i i 阅读全文
posted @ 2020-04-16 16:42 ChevisZhang 阅读(164) 评论(0) 推荐(0)
摘要:思路:本题可转化为求0-n个数里出现了多少个因数5. 1个:5 10 15 20 2个:25 50 75 3个:125 250 所以需要不断的提取因数5 class Solution: def trailingZeroes(self, n: int) -> int: res = 0 while n  阅读全文
posted @ 2020-04-15 18:00 ChevisZhang 阅读(103) 评论(0) 推荐(0)
摘要:由前序排列和中序排列,返回一个二叉树 收获: 1.如果返回结果是树结构,那么需要返回根节点 2.在用递归构造一棵树的时候,结构都是: 1)node = Treenode ( val ) 2) node.left = helper( ) 3) node.right = helper( ) 3. 判断b 阅读全文
posted @ 2020-04-06 18:21 ChevisZhang 阅读(182) 评论(0) 推荐(0)
摘要:AVL,在本题中: 1.由于构造的树的AVL,其子树高度差不超过1. 所以在选值时,要选nums中间的值作为node 2.由于每一颗子树都是AVL,所以需要使用递归 每次都选择区间中值构造Node 代码借鉴官方答案: class TreeNode: def __init__(self, x): se 阅读全文
posted @ 2020-04-06 17:02 ChevisZhang 阅读(204) 评论(0) 推荐(0)
摘要:1,去除字符串两端相同的子串:str2.lstrip(str1), str2.rstrip(str1), str2.strip(str1), 例如: >>> str2='xyz12345xyz'>>> print(str2.lstrip('xyz')+'|'+str2.rstrip('xyz')+' 阅读全文
posted @ 2020-04-05 18:24 ChevisZhang 阅读(2953) 评论(0) 推荐(0)
摘要:Hadoop的思想来源于Google的几篇论文,Google的那篇MapReduce论文里说:Our abstraction is inspired by the map and reduce primitives present in Lisp and many other functional 阅读全文
posted @ 2020-04-02 18:13 ChevisZhang 阅读(159) 评论(0) 推荐(0)