Reverse String

Write a function that takes a string as input and returns the string reversed.

Example:
Given s = "hello", return "olleh".

将给出字符串翻转后输出

   public String reverseString(String s) {
        if(s == null || s.isEmpty()){
            return "";
        }
        char[] array = s.toCharArray();
        for(int i=0,j=s.length()-1; i

时间复杂度O(n),空间复杂度同样

你可能感兴趣的:(Reverse String)