Skip to content

Commit da3ec0e

Browse files
committed
fix index
1 parent cb03937 commit da3ec0e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

shuffling/fisheryates/fisherYates.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export function fisherYates(arr: Array<number>): void {
2-
// for i from n−1 downto 1 do
3-
for(let i = arr.length - 1; i > 0; i++){
4-
const j = Math.floor(Math.random()* i );
2+
for(let i = arr.length - 1; i > 0; i--){
3+
const j = Math.floor(Math.random() * i );
54
const temp = arr[j];
65
arr[j] = arr[i];
76
arr[i] = temp;

0 commit comments

Comments
 (0)