Skip to content

Commit

Permalink
modified: algorithms/cpp/maximumDepthOfBinaryTree/maximumDepthOfBina…
Browse files Browse the repository at this point in the history
…ryTree.cpp

	使用 max 函数以及递归 精简实现
  • Loading branch information
huangxiaofei committed Aug 31, 2016
1 parent 450b9ec commit d31dac6
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ class Solution {
}

};

class Solution2 {
public:
int maxDepth(TreeNode *root) {
if (root==NULL) return 0;
return max(maxDepth(root->left), maxDepth(root->right)) + 1;
}
};

0 comments on commit d31dac6

Please sign in to comment.