educative.io

Educative

Why end index taken as n-2 in solution while reversing string: line no 27

Why end index taken as n-2 in solution while reversing string: line no 27
Is there a space at the end as my solution is not working

The n-2 is because the solution uses a char array for string and the method string.length counts the terminating character as well. The solution has been updated and will be live shortly. You can test the current behavior by printing the return of string.length.