```
var maxDepth = function(root) {
return dfs(root);
function dfs(node) {
if(!node) return 0;
let leftDepth = 1 + dfs(node.left);
let rightDepth = 1 + dfs(node.right);
return leftDepth > rightDepth ? leftDepth : rightDepth;
}
};
```