摘要: 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] has the largest sum = 6.More practice:If you have figured out the O(n) solution, try coding another solution 阅读全文
posted @ 2012-09-25 23:51 ETCOW 阅读(350) 评论(0) 推荐(0) 编辑
摘要: Given a 2D matrix fill with 0's and 1's, find the largest rectangle containing all ones and return its area. 1 public static int MaximalRectangle(List<List<char>> matrix) 2 { 3 int n = matrix.Count; 4 int m = matrix[0].Count; 5 int curr_area = 0; 6... 阅读全文
posted @ 2012-09-25 05:30 ETCOW 阅读(367) 评论(0) 推荐(0) 编辑