O(n) solution doesnt pass last test case, runs out of time?


  • 0
    W

    '''

    public String reverseString(String s) {
    	
    	String reverse = "";
    	
    	for(int i = s.length(); i > 0; i--) {
    
    		reverse = reverse + s.substring(i - 1, i);		
    	}
    	
    	return reverse;
    
        
    }

Log in to reply
 

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