Sorting by Swapping
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 9698 | Accepted: 5191 |
Description
Given a permutation of numbers from 1 to n, we can always get the sequence 1, 2, 3, ..., n by swapping pairs of numbers. For example, if the initial sequence is 2, 3, 5, 4, 1, we can sort them in the following way: