MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / dfs

Function dfs

javascript/0230-kth-smallest-element-in-a-bst.js:14–22  ·  view source on GitHub ↗
(root, k, inOrder)

Source from the content-addressed store, hash-verified

12};
13
14const dfs = (root, k, inOrder) => {
15 if (root.left) kthSmallest(root.left, k, inOrder);
16
17 inOrder.push(root.val);
18
19 if (root.right) kthSmallest(root.right, k, inOrder);
20
21 return inOrder[k - 1];
22};
23
24/**
25 * https://leetcode.com/problems/kth-smallest-element-in-a-bst/

Callers 1

kthSmallestFunction · 0.70

Calls 2

kthSmallestFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected