The 2nd example is incorrect, the output needs to be 2 how can it be 3?


#1

1 1 1 1 2 – if B =3
The best case is to increase mid and 2nd last element by 1 and 1 each and the last attempt would not be used.


#2

Yes, it should be 2 not 3.