摘要:
解法一:递归int countNodes(TreeNode* root){ if (root == NULL) return 0; TreeNode *pLeft = root->left; TreeNode *pRight = root->right; ... 阅读全文
摘要:
解法一:非递归 1 vector preorderTraversal(TreeNode* root) 2 { 3 vector res; 4 if (root == NULL) 5 return res; 6 7 stack node_stack; 8 ... 阅读全文
摘要:
1 struct TreeNode { 2 char val; 3 TreeNode *left; 4 TreeNode *right; 5 int visitCount; //节点访问次数,后序遍历会用到 6 TreeNode(c... 阅读全文