Category : array-algorithms

I recently stumbled upon a problem on HackerEarth. The problem statement asks us to find the min(Arr[i] xor Arr[j]) for the given array In the editorial section, the problem author did something like this sort(a,a+n); long long ans = INT_MAX; for(int i=0;i<n-1;i++) { ans = min(ans, a[i]^a[i+1]); } The author mentioned that the above code ..

Read more

I have a multidimensional array with 20 columns and ‘n’ rows. I’d like to start with the first column, and return the index of the first element in that column satisfying some condition (say, >3). Then, I’d like to move to the second column, and find the index of the ‘nearest element’ satisfying some condition. ..

Read more