上一页 1 ··· 3 4 5 6 7 8 9 10 下一页
摘要: Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative. 1 public static string MultiplyStrings(string num1, string num2) 2 { 3 if (num1.Length == 0 || num2.Length == 0) 4 ... 阅读全文
posted @ 2012-10-01 22:36 ETCOW 阅读(285) 评论(0) 推荐(0) 编辑
摘要: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC".Note:If there is no such window in S that covers all characters in T, return the 阅读全文
posted @ 2012-09-29 03:53 ETCOW 阅读(356) 评论(0) 推荐(0) 编辑
摘要: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any point in time.递归: 1 public static int MinimumPathSum(List<List<int>> grid) 2 { 3 ... 阅读全文
posted @ 2012-09-29 03:32 ETCOW 阅读(291) 评论(0) 推荐(0) 编辑
摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 1 public static ListNode MergeTwoSortedLists(ListNode A, ListNode B) 2 { 3 if (A == null) 4 return B; 5 ... 阅读全文
posted @ 2012-09-29 00:26 ETCOW 阅读(325) 评论(0) 推荐(0) 编辑
摘要: 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 are m and n respectively. 1 public static void MergeSortedArray(int[] A, int m, int[] B, i... 阅读全文
posted @ 2012-09-28 05:04 ETCOW 阅读(295) 评论(0) 推荐(0) 编辑
摘要: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. public class ListNode { public int val; public ListNode next; public ListNode() { } public ListNode(int x) { th... 阅读全文
posted @ 2012-09-27 22:53 ETCOW 阅读(491) 评论(0) 推荐(0) 编辑
摘要: Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]. 1 public static List<Interval> MergeIntervals(List<Interval> intervals) 2 { 3 List<Interval> ret = new List<Interval>(); 4 5 ... 阅读全文
posted @ 2012-09-27 22:40 ETCOW 阅读(387) 评论(0) 推荐(0) 编辑
摘要: 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)). 1 public static double MedianofTwoSortedArrays(int[] A, int[] B) 2 { 3 int m = A.Length; 4 int n... 阅读全文
posted @ 2012-09-26 23:09 ETCOW 阅读(868) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页