Here is the Question link
I understand the given solution mostly But I had one Doubt
int remaining = n - (j - i);
Why would we take remaining n - (j -i) instead of n - (j - i - 1)?
Considering we assume that i and j are the current taken range’s endpoints.
Help is appreciated.