[LeetCode] Maximum Depth of Binary Tree
http://oj.leetcode.com/problems/maximum-depth-of-binary-tree/
史上最简单的题了...
1 class Solution { 2 public: 3 int maxDepth(TreeNode *root) { 4 // IMPORTANT: Please reset any member data you declared, as 5 // the same Solution instance will be reused for each test case. 6 if (root == NULL) { 7 return 0; 8 } 9 return max(maxDepth(root->left) + 1, maxDepth(root->right) + 1); 10 } 11 };