中序遍历二叉树
vector<int> inorderTraversal(TreeNode* root) {
vector<int> inorderTraversalElems;
function<void(TreeNode*& node)> traversal;
traversal = [&](TreeNode*& node)
{
if (node == nullptr) {
return;
}
traversal(node->left);
inorderTraversalElems.push_back(node->val);
traversal(node->right);
};
traversal(root);
return inorderTraversalElems;
}