摘要: 315. 计算右侧小于当前元素的个数 给定一个整数数组 nums,按要求返回一个新数组 counts。数组 counts 有该性质: counts[i] 的值是 nums[i] 右侧小于 nums[i] 的元素的数量。 示例: 输入: [5,2,6,1] 输出: [2,1,1,0] 解释: 5 的右 阅读全文
posted @ 2020-03-22 21:40 7aughing 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 1. quickSort 1 import random 2 class Solution: 3 def partition(self,nums,left,right): 4 idx=random.randint(left,right) # 闭区间 5 pivot=nums[idx] 6 7 num 阅读全文
posted @ 2020-03-22 21:12 7aughing 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 410 分割数组的最小值 1 class Solution(object): 2 def splitArray(self, nums, m): 3 """ 4 :type nums: List[int] 5 :type m: int 6 :rtype: int 7 """ 8 9 n=len(num 阅读全文
posted @ 2020-03-22 11:54 7aughing 阅读(388) 评论(0) 推荐(0) 编辑
摘要: 394. Decode String s = "3[a]2[bc]", return "aaabcbc". s = "3[a2[c]]", return "accaccacc". s = "2[abc]3[cd]ef", return "abcabccdcdcdef". 1 class Soluti 阅读全文
posted @ 2020-03-22 11:23 7aughing 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 当只有一个柱子需要涂色时,有k种可涂色方案; 当有两个柱子需要涂色时,有k(k-1)【diff】+k【same】种涂色方案; 当有三个柱子需要涂色时,有 (same+diff)*(k-1)【diff】+diff【same】种方案。 1 class Solution(object): 2 def nu 阅读全文
posted @ 2020-03-22 11:00 7aughing 阅读(705) 评论(0) 推荐(0) 编辑
摘要: 给你无向 连通 图中一个节点的引用,请你返回该图的 深拷贝(克隆)。 图中的每个节点都包含它的值 val(int) 和其邻居的列表(list[Node])。 class Node { public int val; public List<Node> neighbors; } 测试用例格式: 简单起 阅读全文
posted @ 2020-03-22 09:37 7aughing 阅读(127) 评论(0) 推荐(0) 编辑