fix: change shuffle algo in the doc

This commit is contained in:
RiverTwilight 2023-01-06 08:28:59 +08:00
parent e96272a06f
commit 52927cadad

View File

@ -2337,7 +2337,7 @@ $$
}
// 随机打乱数组元素
for (let i = 0; i < n; i++) {
let r = Math.floor(Math.random() * n);
let r = Math.floor(Math.random() * (i + 1));
let temp = nums[i];
nums[i] = nums[r];
nums[r] = temp;
@ -2381,7 +2381,7 @@ $$
}
// 随机打乱数组元素
for (let i = 0; i < n; i++) {
let r = Math.floor(Math.random() * n);
let r = Math.floor(Math.random() * (i + 1));
let temp = nums[i];
nums[i] = nums[r];
nums[r] = temp;