摘要: 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 initialized in A and B aremandnrespectively.---public class Solution { public void merge(int A[], int m, int B[], int ... 阅读全文
posted @ 2013-09-20 08:19 LEDYC 阅读(119) 评论(0) 推荐(0)
摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of the two partitions.For example,Given1->4->3->2->5->2andx= 3,return1->2->2->4->3- 阅读全文
posted @ 2013-09-20 04:16 LEDYC 阅读(165) 评论(0) 推荐(0)
摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.---1. O(n^3)2. 很想84, largest rectangle in histogra,每一行存以当前行为底的柱状图, 求最大矩形面积。O(N^2)---10/01 YC versionpublic class Solution { public int maximalRectangle(char[][] matrix) { ... 阅读全文
posted @ 2013-09-20 04:10 LEDYC 阅读(361) 评论(0) 推荐(0)
摘要: Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of each bar is 1, given height =[2,1,5,6,2,3].The largest rectangle is shown in the shaded area, which has ar 阅读全文
posted @ 2013-09-20 03:15 LEDYC 阅读(237) 评论(0) 推荐(0)