2 ms·
A variant of bubble sort I think would work. Taking into consideration the 'rotating index', each operation would correctly order three cards within the rotatin
by zxz910 2y ago
A variant of bubble sort I think would work. Taking into consideration the 'rotating index', each operation would correctly order three cards within the rotating index.
In each N pass, we should see each element at least 3 times, and it must advance toward it's desired position at least once. since it can't be at the 'wrong' end of the triple multiple times.
Worst case in N^2 ops we should be done.