- 博客(20)
- 收藏
- 关注
原创 一道凑数问题
题目来源:http://blog.youkuaiyun.com/ljhandlwt/article/details/75014415 给定n,给定池,求池的子集的和为n的个数。池为2^0,2^0,2^1,2^1…包含任意2的次幂,且每个数都有两份。
2017-11-24 17:41:07
1312
原创 Wannafly挑战赛3 A
给你一个长 n 的序列,m 次查询 每次查询给一个 x,然后: 从序列的最左端 1 开始,每次随机的选择一个右端点 r,如果两个端点间的区间和不超过 x ,就进行一次分割,然后把左端点变成 r + 1, 否则一直随机下去。 问这样分割出来的期望段数 n <= 100000 , m <= 500 , 0 <= a[i] <= 1000 , x <= 100
2017-11-24 16:28:42
184
原创 算法概论8.12 K-生成树问题
Problem Description8.12-K生成树问题: 给定K大于等于2,给出无向图G=(V,E),寻找G的一个生成树,其中保证树上任意点度不超过k,或告知不存在这样的生成树。 题目a:k-生成树问题是一个搜索问题。 题目b:k-生成树问题是NP-完全的。(提示:由k=2开始,考虑与Rudrata路径问题的关联)Solution题目a:给出一个G的待确定生成树,枚举每个节点是否
2017-01-08 17:17:36
502
原创 LeetCode #324 Wiggle Sort II
Problem DescriptionGiven an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]….Example:(1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6].
2017-01-08 14:06:18
226
原创 LeetCode #310 Minimum Height Trees
Problem DescriptionFor a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum heig
2017-01-08 02:59:07
252
原创 LeetCode #309 Best Time to Buy and Sell Stock with Cooldown
Problem DescriptionSay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you li
2017-01-08 01:57:15
232
原创 LeetCode #403 Frog Jump
Problem DescriptionA frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.
2017-01-07 22:37:06
314
原创 LeetCode #2#3#5#6#7
2 Add Two NumbersSolution: 指针的简单操作3 Longest Substring Without Repeating CharactersSolution: 开个bool数组记录下每个字符最晚出现的时间点a[s[i]],开个变量作为前一次冲突出现的时间戳k,扫一遍整个串边维护边更新最优值就好了ans=max(ans,i-max(a[s[i]],k-1)。O(n)5
2017-01-07 21:31:51
308
原创 Leetcode #42 #407 Solution
Problem DescriptionGiven an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.Note: Both
2016-10-19 22:18:26
270
原创 leetcode #1 #15 #16 #18 #167 K-Sum Problem Solution
Problem DescriptionGiven an array S of n integers, are there any k elements in S such that a[1]+a[2]+..+a[k] = target? Find all unique quadruplets in the array which gives the sum of target.Some Det
2016-09-28 01:02:50
281
原创 Leetcode #9 Discussion: Only one integer to solve it.
Leetcode #9 Discussion // Rewrite in Markdown mode. 16/9/13
2016-09-13 20:46:58
361
原创 Leetcode #9 Solution
Leetcode #9 Solution// Rewrite in Markdown mode. 16/9/13
2016-09-13 20:10:05
251
原创 Leetcode #56 #338 #344 #292 #371 Solution
Solution of Leetcode #56 #338 #344 #292 #371.
2016-09-13 01:16:15
266
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人