LeetCode oj 344. Reverse String(字符串)
来源:互联网 发布:mac 当前用户路径 编辑:程序博客网 时间:2024/05/17 23:20
344. Reverse String
- Total Accepted: 90670
- Total Submissions: 156010
- Difficulty: Easy
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
Subscribe to see which companies asked this question
字符串翻转
直接翻转的话肯定超时,不然这道题就没有存在的意义了,从两边向中间翻转,可以节约一半的时间
public class Problem344 {public static String reverseString(String s) {char[] str = s.toCharArray();int len = s.length();char strTemp;for(int i=0;i<len/2;i++){strTemp = str[i];str[i] = str[len-1-i];str[len-1-i] = strTemp;}return new String(str);}public static void main(String [] args){System.out.println(reverseString("Heallo"));}}
0 0
- LeetCode oj 344. Reverse String(字符串)
- LeetCode 344. Reverse String(字符串翻转)
- Reverse String | LeetCode OJ
- LeetCode OJ 之 Reverse Words in a String (翻转字符串的单词)
- LeetCode——344. Reverse String(字符串反转)
- LeetCode----344. Reverse String 字符串反转
- [LeetCode]344. Reverse String(反转字符串)
- 字符串- leetcode 344. Reverse String
- leetcode 344. Reverse String 反转字符串
- LeetCode--Reverse String 反转字符串(Python)
- 344. Reverse String (字符串)
- 字符串反转--Leetcode Reverse String
- LeetCode Reverse String(字符串反转)
- LeetCode OJ:Reverse Words in a String
- LeetCode OJ :Reverse Words in a String
- Reverse Words in a String -LeetCode OJ
- Leetcode OJ : Reverse Words in a String
- [LeetCode OJ] Reverse Words in a String
- 统计数据库中的无效网址
- 51nod-1001 数组中和等于K的数对
- JavaScript单线程和浏览器事件循环概述
- The Best Path 并查集 + 欧拉回路
- Bouguet极线校正的方法
- LeetCode oj 344. Reverse String(字符串)
- Java实现图的遍历(深度优先与广度优先遍历)
- 【JDBC】基本操作
- boost库 win7 vs2013安装
- Palindrome
- Grunt介绍与应用
- php中cookies禁用如何获取session
- 球形检测
- 【BZOJ1079】【codevs2428】着色方案,DP