878. Boundary of Binary Tree
/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->val = val; * this->left = this->right = NULL; * } * } */ class Solution { public : /** * @param root: a TreeNode * @return: a list of integer */ vector < int > boundaryOfBinaryTree(TreeNode * root) { // write your code here vector < int > res; if (root == NULL ){ return res; } vector < int > left; //findLeftBoundary(root->left, left); TreeNode *copy = root->left; //这种方法是左右两边边界最后一个会没有取到,最后连起来时,leaves已经包括了,不需要再去重复了。 //这个题开始没有搞出来的原因是,处理left,right时没有从left和right node开始,而是从root开始的,没有分治啊,一定严格分治思想!!!!!! if (copy != NULL ){ while (!(copy->left == NULL && copy->right == NULL )){ left.push_back(copy->val); if (copy->left != NUL...