Hi there, I’ve been trying to figure out some error in my code but I am missing out on something:
you can view my submission here: CodeChef: Practical coding for everyone
The question: CROSBLK Problem - CodeChef
approach:
I am reversing the array to find the next greater element on right, then I run through the NGE jumping from one NGE to another in the array while keeping track of jumps using the following snippet. I also kept track of multiple occurrences of the max value elements as well.
while (i < n){
// cout << i <<"->" << nge[i] << "\n";
i = nge[i];
count++;
}
Only 3 test cases passed. Any help would be appreciated! Thanks!