上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 30 下一页
摘要: 本题思路:三次旋转 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 阅读(153) 评论(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 阅读(94) 评论(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 阅读(172) 评论(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 阅读(193) 评论(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 阅读(2895) 评论(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 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 给定一个链表,每个节点包含一个额外增加的随机指针,该指针可以指向链表中的任何节点或空节点。 要求返回这个链表的 深拷贝。 我们用一个由 n 个节点组成的链表来表示输入/输出中的链表。每个节点用一个 [val, random_index] 表示: val:一个表示 Node.val 的整数。rando 阅读全文
posted @ 2020-03-28 13:09 ChevisZhang 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 收获: 1.在python中对链表中节点进行操作时: a) 从前 我直接 return head (错误) b)现在由于怕 head 会被修改,所以要设 point = Listnode(-1) return point 2. 我自己只想出了两遍遍历,收获了一遍遍历的思路: 双指针 a) 使 fas 阅读全文
posted @ 2020-03-27 23:26 ChevisZhang 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 给定一个非空的整数数组,返回其中出现频率前 k 高的元素。 法1) 使用 Counter 的most_common(k) 方法 from collections import Counter class Solution: def topKFrequent(self, nums: List[int] 阅读全文
posted @ 2020-03-21 18:03 ChevisZhang 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 转自https://blog.csdn.net/hypon2016/article/details/80443649 阅读全文
posted @ 2020-03-17 19:39 ChevisZhang 阅读(176) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 30 下一页