+ 1

I have solved a problem but its not getting accepted.

I have solved a challenge problem but the output is not getting accepted even the answer is correct. The problem is: https://www.sololearn.com/coach/74?ref=app My solution: https://code.sololearn.com/c37BtlhKOrGA/?ref=app

1st Jun 2020, 11:43 PM
Robin Singh
Robin Singh - avatar
4 odpowiedzi
+ 2
Check this. while(i<=(int)s.length()-1){ cout<<s[i]; i++; }
1st Jun 2020, 11:59 PM
Emanuel Maliaño
Emanuel Maliaño - avatar
+ 4
Robin Singh change line 8 to: int i = s.length(); line 18 to: while(i<=(int)s.length()-1){
2nd Jun 2020, 12:33 AM
BroFar
BroFar - avatar
+ 1
BroFar Changing line 8 to i = s.length() would cause the first loop to access out of bound index.
2nd Jun 2020, 4:55 AM
Bobby Fischer
Bobby Fischer - avatar
0
Emanuel Maliaño BroFar and Bobby Fischer Thanks guys only the line 18 was need to be fixed and now its working. while(i<=(int)s.length()-1){}
2nd Jun 2020, 5:16 AM
Robin Singh
Robin Singh - avatar