Category : array-algorithms

https://www.hackerrank.com/contests/cp-tutorial/challenges/cp-tutorial-11/problem below is my solution But the problem I am having is that the output prints the statement exactly the no of times the element is repeated. Can somebody help me out with this.enter image description here #include <iostream> #include <algorithm> using namespace std;“ int main() { int n; cin >> n; int a[1000005]; for(int ..

Read more

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