Confusion with the double quotes --JAVA


  • 0
    L

    Below is my code, it passed if your test case is "hello", but it will not pass if the test case (Run time error) is "hello
    "
    which means you put the double quotes on the next line which is one of the test cases when I submitted my code.

            String x ="";
            for(int i = s.length() - 1;i >= 0;i--){
                x += s.charAt(i);
            }
            return x;
    

    Anyone can answer my question is appreciated. Thank you in advance.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.