9.1 ALT-TAB Window

While using a computer, a user uses the ALT-TAB key to switch between applications.
The ALT-TAB window works on the principle of holding the ALT key for MRU (Most Recently Used) listing.
Hence, the applications arrange themselves in such a way that the most recently used application will be the first item in the ALT-TAB window and so forth.
You are given the list of opened applications and the number of times that the user presses the 'Tab key' to switch between applications.
Find the final arrangement of applications in the ALT-TAB window.

In the given picture. Libraries application is focused, which means that holding the ALT key, the user presses the Tab key twice.
Internet Explorer being the most recently used application followed by Libraries and so on. .

Input Specifications:
line1: N, denoting the number applications currently opened on the system.
line2: K. denoting the number of times user presses Tab key holding the ALT key..
line3: An array containing a list of items numbered from 1 to N. .

Output Specification:
Your function should print the array containing applications in new configurations after k th switch.

Sample Input:
1 2 3 4
Sample Output
3 1 2 4

Explanation :
4 applications are open. Holding the ALT key, the user presses TAB key 3 times.
This pops up application number 3. Hence, 3 is the most active application in the ALT-TAB panel.

Test Case

This challenge is worth 60 points.

You must be logged in to submit a solution

View ranklist for this challenge
About scoring and submission

Contact Us

Kunal Desai : 7715051136

Neelraj Patil : 9930671144

Privacy Policy