![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
文章平均质量分 84
chenshx_sysu
这个作者很懒,什么都没留下…
展开
-
LeetCode 215.Kth Largest Element in an Array O(n)题解
快速选择算法【题目】Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k =原创 2017-02-26 13:35:02 · 508 阅读 · 0 评论 -
LeetCode 18. 4Sum and LeetCode 454. 4Sum II
【题目 LeetCode 18】Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.原创 2017-06-06 17:16:48 · 235 阅读 · 0 评论 -
LeetCode 338. Counting Bits
【题目】Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For原创 2017-05-21 19:12:50 · 189 阅读 · 0 评论 -
LeetCode 309. Best Time to Buy and Sell Stock with Cooldown
【题目】Say 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 like (原创 2017-05-15 19:22:11 · 147 阅读 · 0 评论 -
LeetCode 55. Jump Game and 45. Jump Game II 题解
贪心算法【LeetCode 55. Jump Game】Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length原创 2017-03-26 20:40:13 · 206 阅读 · 0 评论 -
LeetCode 134. Gas Station 题解
【题目】There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i原创 2017-04-03 00:58:32 · 231 阅读 · 0 评论 -
LeetCode 376. Wiggle Subsequence 题解
【题目】A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may b原创 2017-04-10 22:39:02 · 230 阅读 · 0 评论 -
LeetCode 343. Integer Break 题解
【题目】Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given原创 2017-04-16 16:06:06 · 152 阅读 · 0 评论 -
LeetCode 207、Course Schedule 题解
拓扑排序【题目】There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which原创 2017-03-12 12:29:16 · 667 阅读 · 0 评论 -
LeetCode 402. Remove K Digits 题解
贪心算法【题目】Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is less than原创 2017-03-19 17:21:26 · 323 阅读 · 0 评论 -
LeetCode 153. Find Minimum in Rotated Sorted Array
【题目】Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may原创 2017-06-22 10:46:30 · 232 阅读 · 0 评论