i was looking for some D&C algorithms and came out founding this one int sumArray(int anArray[], int size) { //base case if (size == 0) { return 0; } else if (size == 1) { return anArray[0]; } //divide and conquer int mid = size / 2; int rsize = size – mid; int lsum ..

#### 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 ..

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. ..

## Recent Comments