当前位置:网站首页>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 <= 105s[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 --;
}
}
边栏推荐
- Integration of sentinel series Nacos to realize rule synchronization and persistence
- redis
- Feel the power of shardingsphere JDBC through the demo
- Config server configuration center of Nacos series
- 【自动化测试】Cypress手册
- Summary of the 11th week of sophomore year
- mongo
- Tongweb adapts to openrasp
- Basic operations of MySQL auto correlation query
- Wampserver (MySQL) installation
猜你喜欢

20 flowable container (event sub process, things, sub process, pool and pool)

How slow is the application system on tongweb? How dead is it?

MySQL installation, architecture and management

Sentinel series introduction to service flow restriction

About Evaluation Metrics

Mysql database crud operation

17 servicetask of flowable task

The reason why the process cannot be shut down after a spark job is executed and the solution

16 the usertask of a flowable task includes task assignment, multi person countersignature, and dynamic forms

MySQL fuzzy query and sorting by matching degree
随机推荐
Django uses redis to store sessions starting from 0
Mongodb Multi - field Aggregation group by
Problems encountered in the use of PgSQL
Parallelgateway and exclusivegateway of 14 gateways
Bicolor case
SPI primary key generation strategy for shardingsphere JDBC
18 flowable task manualtask and receivetask
16 the usertask of a flowable task includes task assignment, multi person countersignature, and dynamic forms
Sentinel series introduction to service flow restriction
Mobile end adaptation scheme
Basic operations of MySQL auto correlation query
顶部下滑沉浸式dialog
JNDI configuration for tongweb7
Anaconda configuring the mirror source
How to set the import / export template to global text format according to the framework = (solve the problem of scientific counting)
MySQL fuzzy query and sorting by matching degree
Qmessagebox in pyqt5
How MySQL optimizes the use of joint index ABC
Unity game optimization [Second Edition] learning record 6
Working principle of sentinel series (concept)