Here is one more coding challenge that I have solved in HackerEarth.
You are given an array of N integers which is a permutation of the first N natural numbers. You can swap any two elements of the array. You can make at most K swaps. What is the largest permutation, in numerical order, you can make?
Input Format The first line of the input contains two integers, N and K, the size of the input array and the maximum swaps you can make, respectively. The second line of the input contains a permutation of the first N natural numbers.
Output Format Print the lexicographically largest permutation you can make with at most K swaps.
Constraints 1≤N≤105 1≤K≤109
Here is my solution to the above problem written in Python 2.7
Just replace raw_input with input and it should work fine with Python 3
Credits to the Problem Creation: Hackerearth.