0
My output in this challenge is correct but in the SOLOLEARN app it's showing that 5/5 test cases failed.
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);
}
}
+ 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.
+ 2
i got it thank u so much
+ 1
i dont understand plz explain with a program