An array is given. With k swaps, find the maximum number that can be formed using those array elements.
Utilisateur anonyme
Find the maximum number in sub array arr[0, k]. Suppose it was found at index i. If it is greater than arr[0], insert it at 0 just like we do in insertion sort. This will cost us i swaps. With remaining k-i swaps, apply similar logic to subarray starting from index 1 and so on. So when remaining swaps reach 0, current array should be the result.