Question — You are given an array of and you are given a number k . For every i where 1<=i<=k you are given two numbers a and b . a and b are the index of array and you need to swap them . At every swapping there is an new array formed . You need to find the array when we merge all of the numbers make the largest number.
Example — input — n and k where n- total integer in array array value — 1<=array[i]<=1e5
input — 6 3 1 2 3 4 5 6 ------ 1 4 — after swapping a and a array becomes — 423156 ------ 2 5 — after swapping a and a array becomes — 453126 ------ 3 6 — after swapping a and a array becomes — 456123
so if we consider all the 3 numbers the maximum is — 456123
I can tell you my approach but I fail .Intially i was thinking I can take them into string and then just take the maximum out of it but I fail because the array range is from 1 to 1e5 . So if you have any approach help me out. And it is not from any ongoing contest . I dont have any proof for that but it is not.The question is from yesterday off campus test contest and it is over yesterday.