// https://leetcode.com/problems/invert-binary-tree/
// We could do a depth first traversal. Reverse left subtree and right subtree first,
// then reverse left and right link of root.

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    TreeNode* invertTree(TreeNode* root) {
        if (root == nullptr) {
            return nullptr;
        }
        TreeNode* tmp = root->left;
        root->left = invertTree(root->right);
        root->right = invertTree(tmp);
    }
};
Add a solution to problem 226: Invert Binary Tree.
Add a solution to problem 226: Invert Binary Tree.
