Question Link : https://www.codechef.com/JULY20B/problems/CHFNSWPS Chefina has two sequences A1,A2,…,AN and B1,B2,…,BN. She views two sequences with length N as identical if, after they are sorted in non-decreasing order, the i-th element of one sequence is equal to the i-th element of the other sequence for each i (1≤i≤N). To impress Chefina, Chef wants to make […]

- Tags ..., a^n)$ and $(b^1, a[i]); } } return count; } public static int binarySearch(int a[], A2, after they are sorted in non-decreasing order, B, b)) System.out.println(0); else System.out.println(solve(a, b2, Bj). You have to find the minimum total cost with which Chef can make the two sequences identical. Code : /* package codechef; // don't pl, BN. She views two sequences with length N as identical if, Chef wants to make the sequences identical. He may perform the following operation zero or more times: choose two integers i and j (1≤i, High, i1, int high, int low, int n){ int count=0; for(int i=0;i<n;i++){ int x=a[i]; int y=b[i]; if(x==y), int x, int y){ if(low>high) return -1; int mid=low+(high-low)/2; if(x==a[mid]){ if(y==b[mid]), int[][] b, j≤N) and swap Ai with Bj. The cost of each such operation is min(Ai, Low, mid + 1, mid+1, n = 1, n)); } } public static int solve(int a[], Question Link : https://www.codechef.com/JULY20B/problems/CHFNSWPS Chefina has two sequences A1, the i-th element of one sequence is equal to the i-th element of the other sequence for each i (1≤i≤N). To impress Chefina, X, y); } } Can anyone suggest where am I going wrong? Or can someone share few other test cases?, y); } else if(x<a[mid]) return binarySearch(a, y); else return binarySearch(a, y); if(index==-1) return -1; else{ int temp=b[index]; b[index]=a[i];