2013年6月4日
摘要: // 先分析 拆成三段 16ms 过大的 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 8 */ 9 class Solution {10 public:11 ListNode *reverseBetween(ListNode *head, int m, int n) {12 ... 阅读全文
posted @ 2013-06-04 12:09 宇睿 阅读(218) 评论(0) 推荐(0) 编辑
摘要: // 156ms 过大的 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 13 TreeNode *buildTree(vector<int> &preorder,i... 阅读全文
posted @ 2013-06-04 11:03 宇睿 阅读(150) 评论(0) 推荐(0) 编辑
  2013年6月3日
摘要: 1 // 16ms 2 /** 3 * Definition for binary tree 4 * struct TreeNode { 5 * int val; 6 * TreeNode *left; 7 * TreeNode *right; 8 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 9 * };10 */11 class Solution {12 public:13 vector<int> inorderTraversal(TreeNode *root) {14... 阅读全文
posted @ 2013-06-03 20:44 宇睿 阅读(111) 评论(0) 推荐(0) 编辑
摘要: //开始竟然忘了加return 了!! 152ms通过大的 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 13 TreeNode *buildTree(vec... 阅读全文
posted @ 2013-06-03 20:06 宇睿 阅读(134) 评论(0) 推荐(0) 编辑
摘要: //应该用两个栈 16ms 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 vector<vector<int> > zigzagLevelOrder(TreeN... 阅读全文
posted @ 2013-06-03 19:15 宇睿 阅读(135) 评论(0) 推荐(0) 编辑
摘要: // 173ms 1 /** 2 * Definition for binary tree with next pointer. 3 * struct TreeLinkNode { 4 * int val; 5 * TreeLinkNode *left, *right, *next; 6 * TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {} 7 * }; 8 */ 9 class Solution {10 public:11 int flag;12 TreeLinkNo... 阅读全文
posted @ 2013-06-03 16:47 宇睿 阅读(133) 评论(0) 推荐(0) 编辑
摘要: // 4ms 120ms 1 /** 2 * Definition for binary tree with next pointer. 3 * struct TreeLinkNode { 4 * int val; 5 * TreeLinkNode *left, *right, *next; 6 * TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {} 7 * }; 8 */ 9 class Solution {10 public:11 void connect(TreeLink... 阅读全文
posted @ 2013-06-03 15:35 宇睿 阅读(118) 评论(0) 推荐(0) 编辑
摘要: // 4ms 1 class Solution { 2 public: 3 vector<int> getRow(int rowIndex) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 vector<int> v; 7 v.push_back(1); 8 if(rowIndex==0) 9 return v;10 v.push_back(1... 阅读全文
posted @ 2013-06-03 15:12 宇睿 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 vector<vector<int> > generate(int numRows) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 vector<int> v ; 7 vector<vector<int> > re; 8 if(numRows==0) 9 return re;10 ... 阅读全文
posted @ 2013-06-03 14:53 宇睿 阅读(124) 评论(0) 推荐(0) 编辑
摘要: //小的能过,大的内存超限,故大于3000则不处理 :) 1 char edge[3000][3000]={0}; 2 int len[3000]={0}; 3 4 class Solution { 5 public: 6 7 int countL; 8 int findShort() 9 {10 int i,j,k;11 len[0]=0;12 vector<int> q,qq;13 q.push_back(0);14 for( ;q.size(); )15 ... 阅读全文
posted @ 2013-06-03 13:02 宇睿 阅读(177) 评论(0) 推荐(0) 编辑