回溯&深搜&广搜
shiyang6017
这个作者很懒,什么都没留下…
展开
-
Validate Binary Search Tree
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ clas原创 2016-08-06 21:28:34 · 198 阅读 · 0 评论 -
leetcode 44 Wildcard Matching
class Solution {// 必须掌握的一题 public: bool isMatch(string s, string p) { int start_s = -1, // s的索引, start_p = -1,// p的索引,当p[start_p] =='*'时,s此时的索引为start_s i = 0,原创 2016-08-05 20:27:11 · 198 阅读 · 0 评论 -
leetcode Path Sum II
题目:Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. 代码/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo原创 2015-11-27 12:00:21 · 226 阅读 · 0 评论 -
Lowest Common Ancestor of a Binary Tree
Lowest Common Ancestor of a Binary Tree/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), lef原创 2015-11-12 21:38:01 · 231 阅读 · 0 评论 -
leetcode 212. Word Search II
trie + backtracking class Solution { public: vector findWords(vector>& board, vector& words) { TrieNode* root = new TrieNode(); for (auto str : words) insert(root, str); visited.resize(board原创 2016-09-26 21:06:39 · 323 阅读 · 0 评论