LeetCode 344. Reverse String(字符串翻转)

原题网址:https://leetcode.com/problems/reverse-string/

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

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

方法:循环。

public class Solution {
    public String reverseString(String s) {
        if (s == null) return null;
        char[] sa = s.toCharArray();
        char[] r = new char[sa.length];
        for(int i=0; i

你可能感兴趣的:(字符串,翻转,反转)