344. Reverse String

344. Reverse String

   My Submissions
Total Accepted: 10975 Total Submissions: 18784 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

Show Tags
Show Similar Problems
Have you met this question in a real interview? 
Yes
 
No

Discuss


我的解法就是一般的一个一个拆开再赋值:

class Solution {  
public:  
    string reverseString(string s) {  
     string s1;
     int i;
     for(i=s.length()-1;i>=0;i--){
         s1+=s[i];
     }
     return s1;
    }  
}; 
我还在想其他的好方法,谢谢大家啦^_^

posted @ 2016-04-29 19:16  link98  阅读(118)  评论(0)    收藏  举报