Traverse rest of the input
for ( let i = 1 ; i < arr . length ; i ++ ) { if ( arr [ i ] == ' ' ) { al . push ( min_avail ) ; min_avail ++ ; pos_of_I = i + 1 ; } else { al . push ( al [ i ] ) ; for ( let j = pos_of_I ; j <= i ; j ++ ) al [ j ] = al [ j ] + 1 ; min_avail ++ ; } }