首页 > 学院 > 开发设计 > 正文

344. Reverse String

2019-11-11 05:01:31
字体:
来源:转载
供稿:网友

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

Example: Given s = “hello”, return “olleh”.

class Solution {public: string reverseString(string s) { string t; for(int i = s.length() - 1; i >= 0; --i){ t.push_back(s[i]); } return t; }};
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表