Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/neetcode-gh/leetcode
/ invertTree
Function
invertTree
javascript/0226-invert-binary-tree.js:7–12 ·
view source on GitHub ↗
(root)
Source
from the content-addressed store, hash-verified
5
* @
return
{TreeNode}
6
*/
7
var
invertTree = (root) => {
8
const
isBaseCase = root === null;
9
if
(isBaseCase)
return
root;
10
11
return
dfs(root);
12
};
13
14
const
dfs = (root) => {
15
const
left = invertTree(root.left);
Callers
1
dfs
Function · 0.70
Calls
2
dfs
Function · 0.70
bfs
Function · 0.70
Tested by
no test coverage detected