We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c1525da commit 8335741Copy full SHA for 8335741
maximum-depth-of-binary-tree/hsskey.js
@@ -0,0 +1,25 @@
1
+/**
2
+ * Definition for a binary tree node.
3
+ * function TreeNode(val, left, right) {
4
+ * this.val = (val===undefined ? 0 : val)
5
+ * this.left = (left===undefined ? null : left)
6
+ * this.right = (right===undefined ? null : right)
7
+ * }
8
+ */
9
10
+ * @param {TreeNode} root
11
+ * @return {number}
12
13
+var maxDepth = function(root) {
14
+ function dfs(node) {
15
+ if(!node) {
16
+ return 0
17
+ }
18
+
19
+ const left = dfs(node.left)
20
+ const right = dfs(node.right)
21
22
+ return Math.max(left, right) + 1
23
24
+ return dfs(root)
25
+};
0 commit comments