We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 519f557 commit 8e5743fCopy full SHA for 8e5743f
Sorts/CycleSort.js
@@ -15,7 +15,6 @@
15
* @return {number[]} An array of numbers sorted in increasing order.
16
*/
17
function cycleSort (list) {
18
- let writes = 0
19
for (let cycleStart = 0; cycleStart < list.length; cycleStart++) {
20
let value = list[cycleStart]
21
let position = cycleStart
@@ -30,15 +29,13 @@ function cycleSort (list) {
30
29
if (position === cycleStart) {
31
continue
32
}
33
-
34
while (value === list[position]) {
35
position++
36
37
38
const oldValue = list[position]
39
list[position] = value
40
value = oldValue
41
- writes++
42
43
// rotate the rest
44
while (position !== cycleStart) {
@@ -54,7 +51,6 @@ function cycleSort (list) {
54
51
const oldValueCycle = list[position]
55
52
56
53
value = oldValueCycle
57
58
59
60
return list
0 commit comments