当前位置:网站首页>Leetcode- reverse string - simple
Leetcode- reverse string - simple
2022-06-13 05:47:00 【AnWenRen】
title :344 Reverse string - Simple
subject
Write a function , Its function is to invert the input string . Input string as character array s 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) To solve this problem .
Example 1
Input :s = ["h","e","l","l","o"]
Output :["o","l","l","e","h"]
Example 2
Input :s = ["H","a","n","n","a","h"]
Output :["h","a","n","n","a","H"]
Tips
1 <= s.length <= 105
s[i]
All are ASCII Printable characters in code table
Code Java
public void reverseString(char[] s) {
int start = 0;
int end = s.length - 1;
while (start < end) {
char temp = s[start];
s[start] = s[end];
s[end] = temp;
start ++;
end --;
}
}
边栏推荐
- SQL table columns and statements of database
- 计算两个时间相差的天数(支持跨月、跨年)
- Shell instance
- Sentinel series integrates Nacos and realizes dynamic flow control
- Integer tips
- 2021.9.30 learning log -postman
- Problems encountered in the use of PgSQL
- ffmpeg 下载后缀为.m3u8的视频文件
- Fast power code
- Set the correct width and height of the custom dialog
猜你喜欢
3. Postman easy to use
13 cancelendevent of a flowable end event and compensationthrowing of a compensation event
redis
How to Algorithm Evaluation Methods
MySQL performs an inner join on query. The query result is incorrect because the associated fields have different field types.
Sentinel series integrates Nacos and realizes dynamic flow control
Why do so many people hate a-spice
Misunderstanding of tongweb due to ease of use
powershell优化之一:提示符美化
Django uploads local binaries to the database filefield field
随机推荐
How to set the import / export template to global text format according to the framework = (solve the problem of scientific counting)
Why do so many people hate a-spice
Difference between deviation and variance in deep learning
2021.9.29 learning log MIME type
Pyqt5 module
Pychart encountered time zone problem when connecting to MySQL timezone
MySQL performs an inner join on query. The query result is incorrect because the associated fields have different field types.
2021.9.30学习日志-postman
SPI primary key generation strategy for shardingsphere JDBC
mongo
How to Algorithm Evaluation Methods
Building a stand-alone version of Nacos series
powershell优化之一:提示符美化
Fast power code
Error: unmapped character encoding GBK
About Evaluation Metrics
2021.9.29 learning log restful architecture
Windbos common CMD (DOS) command set
Class conflicts caused by tongweb Enterprise Edition and embedded Edition
Integer tips