I have solved a problem but its not getting accepted. | SoloLearn: Learn to code for FREE!

+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

c cpp

6/1/2020 11:43:01 PM

Robin Singh

4 Answers

New Answer

+2

Check this. while(i<=(int)s.length()-1){ cout<<s[i]; i++; }

+4

Robin Singh change line 8 to: int i = s.length(); line 18 to: while(i<=(int)s.length()-1){

+1

BroFar Changing line 8 to i = s.length() would cause the first loop to access out of bound index.

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){}