We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 23aad21 commit 3435324Copy full SHA for 3435324
binary_tree_maximum_node.py
@@ -0,0 +1,19 @@
1
+# coding: utf-8
2
+
3
+class Solution:
4
+ # @param {TreeNode} root the root of binary tree
5
+ # @return {TreeNode} the max node
6
+ def maxNode(self, root):
7
+ if root:
8
+ _max = root
9
+ if root.left:
10
+ left_max = self.maxNode(root.left)
11
+ if _max.val < left_max.val:
12
+ _max = left_max
13
+ if root.right:
14
+ right_max = self.maxNode(root.right)
15
+ if _max.val < right_max.val:
16
+ _max = right_max
17
+ return _max
18
19
+# entry: http://www.lintcode.com/zh-cn/problem/binary-tree-maximum-node/
0 commit comments