educative.io

First Iteration of Outer Loop starts with 1 not 0

as per the code snippet, the outer for loop should starts with 1

for (int i = 1; i < input.length; i++) 

However the dry-run starts with 0. This is the correct behavior?

Hi Sarfraz,
In code snippet, outer loop also starts with i=0
Have a good day!

If outer loop starts with 0 then number of iteration will be 5 not 4. For example 0,1,2,3,4 - please let me know if i am missing something

this depends on value of input.length.
if value of input.length is 5, loop will run for 0,1,2,3,4
if value of input.length is 4, loop will run for 0,1,2,3