Skip to content

Commit 46bd6ff

Browse files
committed
docs: ✏️ update comment about dfs
1 parent 1e85b25 commit 46bd6ff

10 files changed

+10
-0
lines changed

src/0001-1000/133/cloneGraph.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Node } from 'classes/GraphNode'
44
// Time: O(n)
55
// Space: O(n)
66

7+
// 1. dfs
78
function dfs(node: Node, visited: Map<Node, Node>): Node {
89
if (visited.has(node)) {
910
return visited.get(node)!

src/0001-1000/230/kthSmallest2.ts

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class MyBst {
3737
public kthSmallest(k: number): number {
3838
let cur: TreeNode | null = this.root
3939

40+
// 1. dfs
4041
while (cur) {
4142
const leftChildNum = this.getChildNum(cur.left)
4243

src/0001-1000/235/lowestCommonAncestor.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function lowestCommonAncestor(
1717
return root
1818
}
1919

20+
// 1. dfs
2021
if (p!.val < root.val && q!.val < root.val) {
2122
return lowestCommonAncestor(root.left, p, q)
2223
}

src/0001-1000/235/lowestCommonAncestor2.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { TreeNode } from 'classes/BinaryTreeNode'
44
// Time: O(n)
55
// Space: O(n)
66

7+
// 1. dfs
78
function getPath(node: TreeNode, target: TreeNode): TreeNode[] {
89
const path: TreeNode[] = []
910

src/0001-1000/236/lowestCommonAncestor3.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function lowestCommonAncestor(
1414
return root
1515
}
1616

17+
// 1. dfs
1718
const leftChild = lowestCommonAncestor(root.left, p, q)
1819
const rightChild = lowestCommonAncestor(root.right, p, q)
1920

src/0001-1000/450/deleteNode.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function deleteNode(root: TreeNode | null, key: number): TreeNode | null {
1010
return root
1111
}
1212

13+
// 1. dfs
1314
if (root.val > key) {
1415
root.left = deleteNode(root.left, key)
1516
return root

src/0001-1000/669/trimBST.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function trimBST(root: TreeNode | null, low: number, high: number): TreeNode | n
1010
return root
1111
}
1212

13+
// 1. dfs
1314
if (root.val < low) {
1415
return trimBST(root.right, low, high)
1516
}

src/0001-1000/700/searchBST.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function searchBST(root: TreeNode | null, val: number): TreeNode | null {
1313
return root
1414
}
1515

16+
// 1. dfs
1617
return searchBST(val < root.val ? root.left : root.right, val)
1718
}
1819

src/0001-1000/814/pruneTree.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function pruneTree(root: TreeNode | null): TreeNode | null {
1010
return root
1111
}
1212

13+
// 1. dfs
1314
root.left = pruneTree(root.left)
1415
root.right = pruneTree(root.right)
1516

src/1001-2000/1325/removeLeafNodes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function removeLeafNodes(root: TreeNode | null, target: number): TreeNode | null
1010
return root
1111
}
1212

13+
// 1. dfs
1314
root.left = removeLeafNodes(root.left, target)
1415
root.right = removeLeafNodes(root.right, target)
1516

0 commit comments

Comments
 (0)