摘要: For this problem just need to know the structure of two traversal.1. It is hard to find the root node in the inorder traversal but it is easy in posto... 阅读全文
posted @ 2015-03-19 05:27 keepshuatishuati 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Two notes:1. I dont know whether C++ has a good split function for STL as the JAVA. Need to figure it out.2. At the beginning, I tried to set tmp1 = t... 阅读全文
posted @ 2015-03-19 05:11 keepshuatishuati 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Same algorithm with combination. Input as the (1..n), constraint is that the length of each combine should be k. 1 class Solution { 2 public: 3 vo... 阅读全文
posted @ 2015-03-19 04:56 keepshuatishuati 阅读(108) 评论(0) 推荐(0) 编辑
摘要: The different between I and II is that:1. For II, each number only can be chosen ONCE.2. The a number, in the array, encountered more than twice will ... 阅读全文
posted @ 2015-03-19 04:52 keepshuatishuati 阅读(139) 评论(0) 推荐(0) 编辑
摘要: This is a classical combination question. 1 class Solution { 2 public: 3 void getComb(vector > &result, const vector &num, vector current, int sum... 阅读全文
posted @ 2015-03-19 04:39 keepshuatishuati 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-03-19 04:32 keepshuatishuati 阅读(133) 评论(0) 推荐(0) 编辑
摘要: This is pretty simple.Just use three element to pretain the result; 1 class Solution { 2 public: 3 int climbStairs(int n) { 4 vector dp(3,... 阅读全文
posted @ 2015-03-18 09:25 keepshuatishuati 阅读(84) 评论(0) 推荐(0) 编辑
摘要: Two notes:1. result at least n candys. Use array scan from beginning and from end.2. dp[i] = max(dp[i], count++). count++ already record the increasin... 阅读全文
posted @ 2015-03-18 09:22 keepshuatishuati 阅读(91) 评论(0) 推荐(0) 编辑
摘要: Made a stupid bug....... When reverse the vector, stop it at mid. Otherwise, it will swap back......Mark!!!!!!!! 1 /** 2 * Definition for binary tree... 阅读全文
posted @ 2015-03-18 09:12 keepshuatishuati 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Recursive method can be unstand easily:1. Assume we get the sub node with this transition. So we need to make the current node.2. As the symmetic, the... 阅读全文
posted @ 2015-03-18 08:57 keepshuatishuati 阅读(160) 评论(0) 推荐(0) 编辑