101 Symmetric Tree

class Solution {
public:bool isIdentical(const std::vector<int>& n1, const std::vector<int>& n2) {int n = n1.size();for (int i = 0; i < n; i++) {if (n1[i] != n2[n - i - 1]) return false; }return true;}bool isSymmetric(TreeNode* root) {if (!root) return true;queue<TreeNode*> prev;prev.push(root);while (!prev.empty()) {std::vector<int> curr;int size = prev.size();for (int i = 0; i < size; i++) {TreeNode* node = prev.front();prev.pop();if (node) {curr.push_back(node->val); prev.push(node->left); prev.push(node->right); } else {curr.push_back(INT_MIN); }}if (!isIdentical(curr, curr)) {return false;}}return true;}
};
104 Maximum Depth of Binary Tree

class Solution {
public:int DFS(TreeNode* node, int height) {if (!node) return height;if (!node->left && !node->right) {return height + 1;}int leftHeight = DFS(node->left, height + 1);int rightHeight = DFS(node->right, height + 1);return max(leftHeight, rightHeight);}int maxDepth(TreeNode* root) {return DFS(root, 0);}
};