LeetCOde 344. Reverse String
2016-09-03 08:56
471 查看
LeetCOde 344. Reverse String
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
水题,注意判断条件是i<=j 不是i!=j
string reverseString(string s)
{
int len=s.length();
char temp;
for(int i=0,j=len-1;i<=j;i++,j--)
{
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
return s;
}
相关文章推荐
- LeetCode Javascript实现 344. Reverse String 292. Nim Game 371. Sum of Two Integers
- leetcode344. Reverse String
- LeetCode 344:Reverse String (c++)
- LeetCode344——Reverse String(将字符串反转)
- leetcode——344——Reverse String
- leetcode 344 Reverse String (in java)
- Leetcode 344. Reverse String
- 【LeetCode】344. Reverse String
- Leetcode 344. Reverse String (Easy) (cpp)
- reverse string (leetcode 344) java
- LeetCode 344. Reverse String(java)
- [leetcode] 344. Reverse String
- [LeetCode]344. Reverse String
- leetcode 344 Reverse String
- LeetCode 344. Reverse String 对撞指针
- LeetCode 344. Reverse String 题解(C++)
- Leetcode - String - 344. Reverse String (3种写法)
- LeetCode 344: Reverse String 题解
- leetcode 344. Reverse String 题解
- [leetcode 344]Reverse String