Time Limit Exceeded Error


  • 0
    J

    """
    class Solution {
    public String reverseString(String s) {
    int len = s.length();
    if(len<2){
    return s;
    }
    String ans="";
    for(int i=len; i>0; i--){
    ans+=s.charAt(i-1);
    System.out.println(ans);
    }
    return ans;
    }
    }
    """
    I am not sure what is the problem. Could someone please explain?


Log in to reply
 

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