Chefina and Swaps

https://www.codechef.com/JULY20B/problems/CHFNSWPS

I need to understand what will be the answer if the input was:

A => 4 5 5

B=> 3 3 4

According to the solution the answer is 3 but I don’t understand exactly how this happens?

I think i have misunderstood the question, any help will be appreciated.

1 Like

the answer for your Test Case A => 4 5 5 , B=> 3 3 4 will be 3 because, we can swap the pair {3,5} to get A => 4 3 5 and B=> 3 5 4 so that when A and B are sorted they are equal.

1 Like

Oh so i can sort at any moment? I thought I could do only once.

Thank You!

1 Like