上一页 1 2 3 4 5 6 7 8 9 ··· 16 下一页
摘要: Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. Solution: Re... 阅读全文
posted @ 2014-04-20 02:35 beehard 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia... 阅读全文
posted @ 2014-04-19 11:37 beehard 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 vector > generateMatrix(int n) { 4 if (n == 0) return vector >(); 5 vector > res(n, vector(n)); 6... 阅读全文
posted @ 2014-04-16 10:51 beehard 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 vector spiralOrder(vector > &matrix) { 4 vector res; 5 if (matrix.empty() || matrix[0].empty()) re... 阅读全文
posted @ 2014-04-16 08:07 beehard 阅读(119) 评论(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]. Solution... 阅读全文
posted @ 2014-04-16 07:31 beehard 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have ... 阅读全文
posted @ 2014-04-16 05:04 beehard 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list using insertion sort. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *nex... 阅读全文
posted @ 2014-04-15 22:56 beehard 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". Solution: '1'-'0' = 1. 1 class Solution... 阅读全文
posted @ 2014-04-15 13:16 beehard 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the ... 阅读全文
posted @ 2014-04-15 11:41 beehard 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Recursive solution is trivial, could you do it iteratively? Solution: 1. Iterative way (... 阅读全文
posted @ 2014-04-15 11:06 beehard 阅读(174) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 16 下一页