String compression

here i not able to understand when I am trying to do
right <= str.length why is give 1 at the end
but working fine for right < str.length

if the input is “abc” the length of the string is 3
of I m iterating from 0 to 3 for last character if str[2+1] == ‘\0’

@Vikaspal hey dry run for one test case actually it will be less than size ,dry run it you will get it.

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.