摘要: Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root... 阅读全文
posted @ 2014-05-01 23:09 linyx 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 递归:就是出现这种情况的代码: (或者说是用到了栈)解答树角度:在dfs遍历一棵解答树 优点:结构简洁缺点:效率低,可能栈溢出递归的一般结构:1 void f() {2 if(符合边界条件) {3 ///////4 return;5 }6 7 ... 阅读全文
posted @ 2014-05-01 15:14 linyx 阅读(623) 评论(0) 推荐(0) 编辑
摘要: Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinki... 阅读全文
posted @ 2014-05-01 13:14 linyx 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 判断valid,没有更好的方法,只能brute force。 1 class Solution { 2 public: 3 bool isValidSudoku(vector > &board) { 4 5 int n; 6 for (int... 阅读全文
posted @ 2014-05-01 01:25 linyx 阅读(198) 评论(0) 推荐(0) 编辑