For this Question: you have given two integer arrays A and B of length N sorted in non-decreasing order. Calculate the minimum possible difference between elements of A and B.
Solve this problem in O(N) complexity.first- line contains a single integer N
second and third lines contain N space- separated integer A[i] and B[i].Print the minimum absolute difference between two elements from A and B.Sample Input:
6
12 15 16 19 21 29
1 2 3 58 61 65

Sample Output:
9

Explanation : minimum absolute difference can be found between first element of first array and third element of second array., I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int A[n],B[n],ans=INT_MAX;
	for(int &i:A)cin>>i;
	for(int &i:B)cin>>i;
	int i=0,j=0;
	while(i<n && j<n){
		ans=min(ans,abs(A[i]-B[j]));
		if(A[i]<B[j])i++;
		else j++;
	}
	cout<<ans<<endl;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?