I have done a problem, wrote a solution, got accepted. Then I tweaked just 1 line (which was doing the same thing, subtracting 1) but solution got error. I am very confused about what could be the problem, I tried to debug but both cases had same effect while debugging.
Snippet from AC:
const int k = upper_bound(A.begin(), A.end(), t) - A.begin() - 1;
int r = k;
Change in SIGSEGV
const int k = upper_bound(A.begin(), A.end(), t) - A.begin();
int r = k - 1;
Any idea what could have changed between these two codes???
Check line 45 and 47 in both
Accepted Solution
Erroneous Solution