国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

LeetCode 344. Reverse String

2019-11-11 06:48:47
字體:
來源:轉載
供稿:網友

描述 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) { const int n = s.size(); for (size_t i = 0; i < n / 2; ++i) { swap (s[i], s[n - i - 1]); } return s; }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 荥阳市| 资兴市| 阿鲁科尔沁旗| 商都县| 南汇区| 六枝特区| 山丹县| 永康市| 新和县| 福贡县| 晋州市| 油尖旺区| 阿拉善左旗| 新余市| 宣化县| 利川市| 丰台区| 廉江市| 秦皇岛市| 紫金县| 旌德县| 精河县| 北安市| 黎川县| 新乡县| 平陆县| 宁武县| 微博| 自治县| 拜泉县| 闸北区| 都匀市| 大冶市| 胶州市| 班戈县| 安化县| 华安县| 土默特右旗| 富平县| 策勒县| 盐池县|