LeetCode 344. 反转字符串
LeetCode 字符串 反转
2023-09-11 14:19:00 时间
思路
方法:首尾双指针
1 class Solution { 2 public: 3 void reverseString(vector<char>& s) { 4 int i = 0, j = s.size()-1; 5 while(i < j) { 6 swap(s[i], s[j]); 7 ++i; 8 --j; 9 } 10 } 11 };
相关文章
- 看完谷歌大佬的 LeetCode 刷题笔记,我马上去字节跳动面试!
- Leetcode: Maximum Product of Word Lengths
- Leetcode: Surrounded Regions
- [LeetCode]Remove Element
- JS leetcode II. 左旋转字符串 题解分析
- JS leetcode 反转字符串 题解分析
- [LeetCode][类实现]5422. 子矩形查询
- [LeetCode]344. 反转字符串
- LeetCode 394. 字符串解码
- 【LeetCode】191. Number of 1 Bits
- [LeetCode] 1316. Distinct Echo Substrings 不同的循环子字符串
- [LeetCode] 1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold 元素和小于等于阈值的正方形的最大边长
- [LeetCode] 1247. Minimum Swaps to Make Strings Equal 交换字符使得字符串相同
- [LeetCode] 1047. Remove All Adjacent Duplicates In String 移除字符串中所有相邻的重复字符
- [LeetCode] 988. Smallest String Starting From Leaf 从叶结点开始的最小字符串
- [LeetCode] 972. Equal Rational Numbers 相等的有理数
- [LeetCode] 942. DI String Match 增减DI字符串匹配
- [LeetCode] 829. Consecutive Numbers Sum 连续数字之和
- [LeetCode] 854. K-Similar Strings 相似度为K的字符串
- [LeetCode] 251. Flatten 2D Vector 压平二维向量
- [LeetCode] 249. Group Shifted Strings 群组偏移字符串
- [LeetCode] 186. Reverse Words in a String II 翻转字符串中的单词之二
- [LeetCode] 205. Isomorphic Strings 同构字符串
- [LeetCode] 6. ZigZag Conversion 之字型转换字符串
- LeetCode二叉树的最大深度
- leetcode 205. Isomorphic Strings 同构字符串(简单)