摘要: Problem description:http://oj.leetcode.com/problems/sum-root-to-leaf-numbers/Basic idea:To store the num vector in every node of tree by starting from leaf, the go up util to root. 1 class Solution { 2 public: 3 vector> subNumbers(TreeNode *root) { 4 vector> sums; 5 if(root == NU... 阅读全文
posted @ 2013-10-27 07:35 假日笛声 阅读(274) 评论(0) 推荐(0) 编辑
摘要: Problem description:http://oj.leetcode.com/problems/symmetric-tree/Basic idea:Both recursive and iterative solutions.Iterative solution: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x)... 阅读全文
posted @ 2013-10-27 07:06 假日笛声 阅读(178) 评论(0) 推荐(0) 编辑