File tree Expand file tree Collapse file tree 1 file changed +0
-4
lines changed
Expand file tree Collapse file tree 1 file changed +0
-4
lines changed Original file line number Diff line number Diff line change 1515 * @return {number[] } An array of numbers sorted in increasing order.
1616 */
1717function cycleSort ( list ) {
18- let writes = 0
1918 for ( let cycleStart = 0 ; cycleStart < list . length ; cycleStart ++ ) {
2019 let value = list [ cycleStart ]
2120 let position = cycleStart
@@ -30,15 +29,13 @@ function cycleSort (list) {
3029 if ( position === cycleStart ) {
3130 continue
3231 }
33-
3432 while ( value === list [ position ] ) {
3533 position ++
3634 }
3735
3836 const oldValue = list [ position ]
3937 list [ position ] = value
4038 value = oldValue
41- writes ++
4239
4340 // rotate the rest
4441 while ( position !== cycleStart ) {
@@ -54,7 +51,6 @@ function cycleSort (list) {
5451 const oldValueCycle = list [ position ]
5552 list [ position ] = value
5653 value = oldValueCycle
57- writes ++
5854 }
5955 }
6056 return list
You can’t perform that action at this time.
0 commit comments