![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
code-数组
chunxia75qin
这个作者很懒,什么都没留下…
展开
-
Subsets II
题目:Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain原创 2013-05-29 16:57:53 · 637 阅读 · 0 评论 -
Surrounded Regions
题目:Given a 2D board containing 'X' and 'O', capture all regions surrounded by'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region .For example,X X X XX O O X原创 2013-06-07 19:25:45 · 484 阅读 · 0 评论 -
Longest Consecutive Sequence
题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1,原创 2013-06-06 12:03:33 · 450 阅读 · 0 评论 -
Merge Sorted Array
题目:Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements initialize原创 2013-05-28 13:19:47 · 645 阅读 · 0 评论 -
Best Time to Buy and Sell Stock III
题目:Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You ma原创 2013-06-05 10:54:48 · 742 阅读 · 0 评论 -
Triangle
题目:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4],原创 2013-06-04 15:59:23 · 676 阅读 · 0 评论 -
Pascal's Triangle II
题目:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?代码如下:vect原创 2013-06-04 15:26:05 · 548 阅读 · 0 评论 -
Pascal's Triangle
题目:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]代码如下:vector > genera原创 2013-06-04 15:14:55 · 719 阅读 · 0 评论 -
Best Time to Buy and Sell Stock II
题目:Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie,原创 2013-06-05 10:09:01 · 806 阅读 · 0 评论 -
Best Time to Buy and Sell Stock
题目:Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the s原创 2013-06-05 09:50:10 · 808 阅读 · 0 评论 -
Median of Two Sorted Arrays
题目:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).代码如下:int func(int *A, int m,原创 2013-07-23 18:13:38 · 448 阅读 · 0 评论