0

My output in this challenge is correct but in the SOLOLEARN app it's showing that 5/5 test cases failed.

https://code.sololearn.com/cK7bJmCd522F/?ref=app

26th May 2020, 10:05 AM
Arihant Kumar
Arihant Kumar - avatar
4 Antworten
+ 3
Change; char ans[]= new char[50] to String and = ""; and in your loop change; ans[n]=ch; to ans += ch; Then System.out.println(ans); And remove the variable int n=0; n++; It's no longer needed. -------------------------------------- OR You can just output the char in loop. String s = new Scanner(System.in).nextLine(); for(int i=s.length()-1 ; i>=0 ; i--) { char ch= s.charAt(i); if(Character.isLetter(ch) || Character.isWhitespace(ch) { System.out.print(ch); } }
27th May 2020, 7:04 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
If you change ans to a string instead of a char array and then just append ch to it then just output ans it works. Or if you just use print in the loop and output each valid char it also works.
26th May 2020, 10:48 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
i got it thank u so much
27th May 2020, 8:56 AM
Arihant Kumar
Arihant Kumar - avatar
+ 1
i dont understand plz explain with a program
27th May 2020, 6:52 AM
Arihant Kumar
Arihant Kumar - avatar