Exactly! The complete code gives a full picture. Without it, there is always an uncertainity of " are we even looking in right direction?"
Hackerrank solutions are usually privateā¦
canāt post the entire code as it is from ongoing contest.
btw it was because of garbage value and not problem of upper_bound.
- Make sure your array is sorted.
2)Before checking the value of A, make sure the element exists in the array.After you confirm the existence of the element then find the index!