LeetCode——Reverse String

LeetCode——Reverse String

Question

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

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

Answer

class Solution {
public:
    string reverseString(string s) {
        string str(s.rbegin(), s.rend());
        return str;
    }
};
posted @ 2017-04-02 09:42  清水汪汪  阅读(121)  评论(0编辑  收藏  举报