摘要: Given an array of integers, find two non-overlapping subarrays which have the largest sum. The number in each subarray should be contiguous. Return th 阅读全文
posted @ 2016-04-02 11:33 YuriFLAG 阅读(209) 评论(0) 推荐(0)
摘要: 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 whic 阅读全文
posted @ 2016-04-02 10:31 YuriFLAG 阅读(151) 评论(0) 推荐(0)
摘要: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2016-04-02 09:39 YuriFLAG 阅读(156) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2016-04-02 09:09 YuriFLAG 阅读(132) 评论(0) 推荐(0)
摘要: Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime 阅读全文
posted @ 2016-04-02 09:03 YuriFLAG 阅读(139) 评论(0) 推荐(0)
摘要: 思路: 1.Divide & Conquer 2.Merge sorted list. 阅读全文
posted @ 2016-03-31 11:05 YuriFLAG 阅读(104) 评论(0) 推荐(0)
摘要: Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 阅读全文
posted @ 2016-03-31 10:14 YuriFLAG 阅读(141) 评论(0) 推荐(0)
摘要: Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest i 阅读全文
posted @ 2016-03-31 09:09 YuriFLAG 阅读(165) 评论(0) 推荐(0)
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. Example Given the followi 阅读全文
posted @ 2016-03-30 08:40 YuriFLAG 阅读(150) 评论(0) 推荐(0)
摘要: 春节期间小明使用微信收到很多个红包,非常开心。在查看领取红包记录时发现,某个红包金额出现的次数超过了红包总数的一半。请帮小明找到该红包金额。写出具体算法思路和代码实现,要求算法尽可能高效。 给定一个红包的金额数组gifts及它的大小n,请返回所求红包的金额。 测试样例: 阅读全文
posted @ 2016-03-27 09:58 YuriFLAG 阅读(315) 评论(0) 推荐(0)