分治
文章平均质量分 57
Juxin_Lin
这个作者很懒,什么都没留下…
展开
-
【LeetCode】53. Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1] ha原创 2017-01-08 10:42:39 · 318 阅读 · 0 评论 -
【LeetCode】 215. Kth Largest Element in an Array
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 = 2, return 5.原创 2017-01-08 16:46:57 · 810 阅读 · 0 评论 -
【LeetCode】169. Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element原创 2017-01-08 16:52:50 · 270 阅读 · 0 评论 -
【LeetCode】241. Different Ways to Add Parentheses
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.Example 1原创 2017-01-08 16:55:40 · 292 阅读 · 0 评论 -
【LeetCode】50. Pow(x, n)
Difficulty: MediumImplement pow(x, n).Subscribe to see which companies asked this question分析二分法,x^n=x^(n/2) * x^(n/2) * x^(n%2),时间复杂度O(logn)class Solution {public:原创 2017-01-14 16:21:49 · 312 阅读 · 0 评论 -
【LeetCode】69. Sqrt(x)
Difficulty: MediumImplement int sqrt(int x).Compute and return the square root of x.Subscribe to see which companies asked this question二分查找,时间复杂度O(logn)class Solution {publ原创 2017-01-14 16:35:44 · 259 阅读 · 0 评论