What is the mistake I have done here ,can someone explain please? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

What is the mistake I have done here ,can someone explain please?

Problem in a code ,help. https://code.sololearn.com/c068N3b4t0OR/?ref=app

2nd Apr 2020, 7:59 AM
Rajan krishnan
Rajan krishnan - avatar
2 Respostas
+ 2
Assume the input is "Carrie". Carrie 012345 - The last index is 5. But the length of the string is 6. In the first loop it won't found index 6 and cause error. You can do for(i = l-1 ; i>=0 ; i--) to avoid it.
2nd Apr 2020, 8:07 AM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ - avatar
+ 1
Thanks ,got itšŸ‘ I m a newbie in java now.
2nd Apr 2020, 8:13 AM
Rajan krishnan
Rajan krishnan - avatar