摘要: Problem Description:http://oj.leetcode.com/problems/word-search/Basic idea: recursively go forward, use char '#' to mark the char visited, so no extra memory is need, don't forget to recover the previous char if the program cannot go forward. 1 class Solution { 2 public: 3 bool existSub( 阅读全文
posted @ 2013-10-18 14:48 假日笛声 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Problem Description:http://oj.leetcode.com/problems/same-tree/ 1 class Solution { 2 public: 3 bool isSameTree(TreeNode *p, TreeNode *q) { 4 // Note: The Solution object is instantiated only once and is reused by each test case. 5 if(p == NULL && q == NULL) 6 return tr... 阅读全文
posted @ 2013-10-18 06:14 假日笛声 阅读(151) 评论(0) 推荐(0) 编辑