Skip to content

Commit 002f09e

Browse files
133. Clone Graph in BFS
1 parent 6b418dc commit 002f09e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ Mistakes
2121

2222

2323
Approach #2 BFS
24-
1. Take a clone node and map, node which are cloned keep adding into the map
24+
1. Take a clone node and array of 101 len (check constrain), node which are cloned keep adding into the array on Val index
2525
2. Add visited node into the queue, run unit queue is empty
2626
1. pop for queue
2727
2. for each neighbor
28-
1. if neighbor is map, add it neighbor of pop node
29-
2. else clone it, add into the map, add as a neighbor pf pop node
28+
1. if neighbor is not in array, add it neighbor into array, adding into queue
29+
2. (no else, for all) get the cloned neighbor from array and adding to cloned curr node (find in array by currNode.Val)
3030

3131

3232

0 commit comments

Comments
 (0)