当前位置:网站首页>Leetcode question brushing: String 01 (inverted string)
Leetcode question brushing: String 01 (inverted string)
2022-06-26 20:49:00 【Taotao can't learn English】
344. Reverse string
Write a function , Its function is to invert the input string . Input string as character array char[] Given in the form of .
Do not allocate extra space to another array , You have to modify the input array in place 、 Use O ( 1 ) O(1) O(1) To solve this problem .
You can assume that all characters in an array are ASCII Printable characters in code table .
Example 1:
Input :[“h”,“e”,“l”,“l”,“o”]
Output :[“o”,“l”,“l”,“e”,“h”]
Example 2:
Input :[“H”,“a”,“n”,“n”,“a”,“h”]
Output :[“h”,“a”,“n”,“n”,“a”,“H”]
This question is simply not too simple for me who just finished the sum of four numbers of the double pointer method
public void reverseString(char[] s) {
// Double finger needling
int left = 0;
int right = s.length - 1;
while (left < right) {
char temp = s[left];
s[left] = s[right];
s[right] = temp;
left++;
right--;
}
}

you 're right , Again AC. Powerful .
边栏推荐
- What are the specific steps for opening a stock account? Is it safe to open an account online?
- 【最详细】最新最全Redis面试大全(42道)
- Invocation failed Unexpected end of file from server
- Daily basic use of alicloud personal image warehouse
- Sentinelresource annotation details
- Garbage collection mechanism of browser
- Tiktok practice ~ sharing module ~ copy short video link
- Flutter TextField详解
- 30. 串联所有单词的子串
- The postgraduate entrance examination in these areas is crazy! Which area has the largest number of candidates?
猜你喜欢

Detailed explanation of shutter textfield

GEE:计算image区域内像素最大最小值

Tiktok practice ~ sharing module ~ generate short video QR code

论数据库的传统与未来之争之溯源溯本----AWS系列专栏

leetcode刷题:字符串02( 反转字符串II)

On the origin of the dispute between the tradition and the future of database -- AWS series column

【贝叶斯分类4】贝叶斯网

Idea error: process terminated

Database SQL statement writing

Introduction to single chip microcomputer one-on-one learning strategy, independent development program immediately after reading
随机推荐
0 basic C language (3)
Flutter TextField详解
Daily basic use of alicloud personal image warehouse
Gee: calculate the maximum and minimum values of pixels in the image area
[serialization] how to master the core technology of opengauss database? Secret 5: master database security (6)
515. find the maximum value in each tree row
515. 在每个树行中找最大值
浏览器的垃圾回收机制
动态规划111
[recommended collection] these 8 common missing value filling skills must be mastered
Can I open an account online? Is it safe?
Gamefi active users, transaction volume, financing amount and new projects continue to decline. Can axie and stepn get rid of the death spiral? Where is the chain tour?
云计算技术的发展与芯片处理器的关系
西瓜书重温(七): 贝叶斯分类器(手推+代码demo)
leetcode刷题:字符串01(反转字符串)
460million zongzi were sold in half a year. How big is the "imagination space" of time-honored brands?
好物推薦:移動端開發安全工具
飞天+CIPU体为元宇宙带来更大想象空间
Tiktok practice ~ sharing module ~ copy short video link
Detailed explanation of stored procedures in MySQL