题解 | #反转字符串#

反转字符串

http://www.nowcoder.com/practice/c3a6afee325e472386a1c4eb1ef987f3



public class Solution {
    /**
     * 反转字符串
     * @param str string字符串 
     * @return string字符串
     */
  public static String solve (String str) {
        int len=str.length();
        if(len==0||len==1){
            return str;
        }
        String res=new String();
        for(int index=len-1;index>=0;index--){
            res=res+str.charAt(index);
        }
        return res;
    }
}
全部评论

相关推荐

码农索隆:想看offer细节
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务