Find the common length part, then check with two pointers. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 *...
分类:
其他好文 时间:
2015-03-20 06:57:04
阅读次数:
135
Similar to merge intervals. But this is easier than merge interval, because every side is kind of "sorted". 1 /** 2 * Definition for an interval. 3 .....
分类:
其他好文 时间:
2015-03-20 06:50:10
阅读次数:
123
/* 给一颗二叉树,问是否关于中心对称*//** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNod...
分类:
其他好文 时间:
2015-03-19 23:46:10
阅读次数:
152
/*判断一颗二叉树是否是平衡二叉树(左右子节点的高度差不超过1或者是颗空树)*//** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *righ...
分类:
其他好文 时间:
2015-03-19 23:28:57
阅读次数:
200
Only different with preorder and postorder is that the root start from the beginning for preorder. 1 /** 2 * Definition for binary tree 3 * struct T.....
分类:
其他好文 时间:
2015-03-19 06:20:26
阅读次数:
122
1. Use BFS to search the graph.2. Create a hashtable to record the one to one mapping. 1 /** 2 * Definition for undirected graph. 3 * struct Undirec.....
分类:
其他好文 时间:
2015-03-19 06:19:16
阅读次数:
125
先序遍历:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), ...
分类:
其他好文 时间:
2015-03-18 13:48:17
阅读次数:
124
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull./** * Definition for singly-linked list. * class ListNod...
分类:
其他好文 时间:
2015-03-18 13:45:39
阅读次数:
107
Made a stupid bug....... When reverse the vector, stop it at mid. Otherwise, it will swap back......Mark!!!!!!!! 1 /** 2 * Definition for binary tree....
分类:
其他好文 时间:
2015-03-18 10:23:29
阅读次数:
120
Basic question. Use a queue to store Node, use two numbers to record current level node numbers and next level node numbers. 1 /** 2 * Definition for....
分类:
其他好文 时间:
2015-03-18 08:58:27
阅读次数:
105