Please look at this submission. I am getting out of bounds error on line number 42. I have checked my code multiple times and also made sure that the vector 'a' is accessed up to i=a.size()-2 only, so that a[i+1] doesn't go out of bound.
Please help me identify my mistake.
I will be thankful for any help!
Captain Obvious to rescue:
If
a.size() == 1
thena.size() - 2 == numeric_limits<size_t>::max() - 1
P.S. In DM I got corrected, it just
numeric_limits<size_>::max()
Thanks so much! How can I fix that?
Type cast it to integer then compare.