344. Reverse String
来源:互联网 发布:java项目开发实战案例 编辑:程序博客网 时间:2024/05/22 12:11
Write a function that takes a string as input and returns the string reversed.
Example:
Example:
Given s = "hello", return "olleh".
Answer:
public class Solution { public String reverseString(String s) { StringBuilder temp = new StringBuilder(); for(int i=0;i<s.length();i++){ char c =s.charAt(i); temp.insert(0,c); } return temp.toString(); }}
思路:翻转字符串。通过StringBuilder的insert方法,可以将每个字符重新插入进新的字符串中,返回即可。
阅读全文
0 0
- String:344. Reverse String
- 344.Reverse String(String-Easy)
- leetcode--344. Reverse String
- 344. Reverse String
- 344. Reverse String [E]
- LeetCode 344. Reverse String
- 344. Reverse String
- LeetCode 344. Reverse String
- 344. Reverse String
- 344. Reverse String
- 344. Reverse String
- Leetcode:344. Reverse String
- 344. Reverse String
- LeetCode *** 344. Reverse String
- 344. Reverse String
- LeetCode *** 344. Reverse String
- 344. Reverse String
- [leetcode] 344. Reverse String
- scala中处理json数据
- Spring security注销登录
- inline函数的一些总结
- txt保存的样本转为矩阵
- ajax例子
- 344. Reverse String
- 启动redis本地服务
- 【Android前端】Bing每日图片列表应用制作记录——2.列表的实现
- 【欧拉计划 P4】Largest palindrome product 最大的回文数
- Java基础----字节流
- 十个JDBC的最佳实践
- CSU1215
- 读《程序员》2017年5期
- SFTPUtils工具类及使用