# Find maximum number

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.

1<=n,k<=1e5

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[1] and a[4] array becomes — 423156 ------ 2 5 — after swapping a[2] and a[5] array becomes — 453126 ------ 3 6 — after swapping a[3] and a[6] 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.

thankyou.

@shravan660 If you sort it your index position differ and you are end up getting wrong answer .If you tell me with an example its better.

anyone know how to solve this…