LeetCode 344. Reverse String

来源:互联网 发布:最新淘宝黑车技术 编辑:程序博客网 时间:2024/05/15 03:52

Write a function that takes a string as input and returns the string reversed.

Example:

Given s = "hello", return "olleh".

开始玩LeetCode了,不过这个OJ代码风格好奇怪,C++代码强制用类编写。

class Solution {public:    string reverseString(string s) {                string ss = "";        int len = s.size();        while(len){            ss += s[len - 1];            len --;        }        return ss;    }};


0 0