sir just check this code
if i create blank vector and do v.size() it gives 0 thats right
but if i do v.size()-1 than it should give -1 isnt it?? that is 0-1=-1
but its showing very big number why here is the code
sir just check this code
if i create blank vector and do v.size() it gives 0 thats right
but if i do v.size()-1 than it should give -1 isnt it?? that is 0-1=-1
but its showing very big number why here is the code
@tejasddongare you are right!
this happens because v.size() results in an unsigned int, so v.size()-1 will never give a negative value, instead it will roll over to approx 2*MAX - 1 (MAX is largest value of signed long long)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.