摘要:
1 class Solution { 2 public: 3 /** 4 * @param s A string 5 * @return Whether the string is a valid palindrome 6 */ 7 bool isPa... 阅读全文
摘要:
1 class Solution { 2 public: 3 /** 4 * @param s A string 5 * @return whether the string is a valid parentheses 6 */ 7 bool isV... 阅读全文
摘要:
递归实现: 1 /** 2 * Definition of TreeNode: 3 * class TreeNode { 4 * public: 5 * int val; 6 * TreeNode *left, *right; 7 * TreeNode(int v... 阅读全文
摘要:
1 class MinStack { 2 public: 3 MinStack() { 4 // do initialization if necessary 5 } 6 7 void push(int number) { 8 // wri... 阅读全文
摘要:
1 class Queue { 2 public: 3 stack stack1; 4 stack stack2; 5 6 Queue() { 7 // do intialization if necessary 8 } 9 10 void... 阅读全文
摘要:
1 class Solution { 2 public: 3 /** 4 * @param A, B: Two strings. 5 * @return: The length of longest common subsequence of A and B. 6 ... 阅读全文
摘要:
1 class Solution { 2 public: 3 /** 4 * @param A, B: Two string. 5 * @return: the length of the longest common substring. 6 */ ... 阅读全文
摘要:
Well, this problem is spiritually similar to toCourse Schedule. You only need to store the nodes in the order you visit into a vector during BFS or DF... 阅读全文
摘要:
As suggested by the hints, this problem is equivalent to detecting a cycle in the graph represented byprerequisites. Both BFS and DFS can be used to s... 阅读全文