Feb-29-2020, 05:51 AM
ok,but where to add those extra print statements and which are the right branches which could satisfy below conditions in this program:-
nput:-
First line contains one integer 1<=N<=1000,number of pairs.
Next N line contains 2 space separated integers representing a pair {i,j} in current list.
Output Format:-
Print one integer,that is minimum number of swaps needed to make the list good looking
Sample Input 1:
3
1 3
0 2
4 5
Sample Output 1:
1
Explanation:
If we swap 0 and 3 list becomes (1,0),(3,2) and (4,5),which is a good looking list.
Sample Input 2:
2
3 2
0 1
Sample Output 2:
0
Explanation:
List is already good looking.
nput:-
First line contains one integer 1<=N<=1000,number of pairs.
Next N line contains 2 space separated integers representing a pair {i,j} in current list.
Output Format:-
Print one integer,that is minimum number of swaps needed to make the list good looking
Sample Input 1:
3
1 3
0 2
4 5
Sample Output 1:
1
Explanation:
If we swap 0 and 3 list becomes (1,0),(3,2) and (4,5),which is a good looking list.
Sample Input 2:
2
3 2
0 1
Sample Output 2:
0
Explanation:
List is already good looking.