We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb03937 commit da3ec0eCopy full SHA for da3ec0e
shuffling/fisheryates/fisherYates.ts
@@ -1,7 +1,6 @@
1
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 );
+ for(let i = arr.length - 1; i > 0; i--){
+ const j = Math.floor(Math.random() * i );
5
const temp = arr[j];
6
arr[j] = arr[i];
7
arr[i] = temp;
0 commit comments