当前位置:网站首页>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 .
边栏推荐
- Button how to dynamically set drawablebottom (setcomposunddrawables is invalid)
- MongoDB实现创建删除数据库、创建删除表(集合)、数据增删改查
- Detailed explanation of retrospective thinking
- Sword finger offer II 091 Paint the house
- 2022/02/14 line generation
- Is it safe to open an online account in case of five-year exemption?
- StringUtils判断字符串是否为空
- Two methods of QT to realize timer
- Muke 11. User authentication and authorization of microservices
- Sentinelresource annotation details
猜你喜欢
Gee: calculate the maximum and minimum values of pixels in the image area
清华大学就光刻机发声,ASML立马加紧向中国出口光刻机
Flutter TextField详解
Guomingyu: Apple's AR / MR head mounted display is the most complicated product in its history and will be released in January 2023
动态规划111
Development of NFT for digital collection platform
慕课11、微服务的用户认证与授权
GEE:计算image区域内像素最大最小值
Disruptor local thread queue_ Use transprocessor processor and workpool to compare consumption - Notes on inter thread communication 005
郭明錤:苹果 AR / MR 头显是其有史以来设计最复杂的产品,将于 2023 年 1 月发布
随机推荐
Arduino uno + DS1302 uses 31 byte static RAM to store data and print through serial port
网上开户万一免五到底安不安全?
c语言简单的登录
JWT operation tool class sharing
Establish a connection with MySQL
C: 反转链表
Garbage collection mechanism of browser
[most detailed] the latest and complete redis interview (70)
分布式ID生成系统
Sword finger offer II 091 Paint the house
windows系統下怎麼安裝mysql8.0數據庫?(圖文教程)
Stringutils judge whether the string is empty
【最详细】最新最全Redis面试大全(70道)
leetcode刷题:字符串02( 反转字符串II)
与 MySQL 建立连接
清华大学就光刻机发声,ASML立马加紧向中国出口光刻机
SentinelResource注解詳解
Dynamic parameter association using postman
GEE:计算image区域内像素最大最小值
windows系统下怎么安装mysql8.0数据库?(图文教程)