当前位置:网站首页>Leetcode- reverse vowels in string - simple
Leetcode- reverse vowels in string - simple
2022-06-13 05:47:00 【AnWenRen】
title :345 Reverse vowels in a string - Simple
subject
Give you a string
s
, Invert only all vowels in the string , And return the result string .Vowels include
'a'
、'e'
、'i'
、'o'
、'u'
, And may appear in both case .
Example 1
Input :s = "hello"
Output :"holle"
Example 2
Input :s = "leetcode"
Output :"leotcede"
Tips
1 <= s.length <= 3 * 105
s
from Printable ASCII Character composition
Code Java
public String reverseVowels(String s) {
int start = 0;
int end = s.length()-1;
char[] str = s.toCharArray();
while (start < end) {
while(start < str.length){
char x = str[start];
if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'
|| x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U') {
break;
}
start ++;
}
while(end >= 0){
char x = str[end];
if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'
|| x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U') {
break;
}
end --;
}
if (start < end){
char temp = str[start];
str[start] = str[end];
str[end] = temp;
start ++;
end --;
} else break;
}
return new String(str);
}
边栏推荐
- Four shardingsphere JDBC sharding strategies
- Implementation of concurrent programming locking
- Three paradigms of MySQL
- MySQL transactions and foreign keys
- Exception after repeated application redeployment on tongweb: application instance has been stopped already or outofmemoryerror:metaspace
- Use the browser to cut the entire page (take chrome as an example)
- Basic operations of MySQL auto correlation query
- 18 flowable task manualtask and receivetask
- ffmpeg 下载后缀为.m3u8的视频文件
- 19 calling subprocess (callactivity) of a flowable task
猜你喜欢
17 servicetask of flowable task
Timeout thread log for tongweb
19 calling subprocess (callactivity) of a flowable task
16 the usertask of a flowable task includes task assignment, multi person countersignature, and dynamic forms
Solution to prompt "permission is required to perform this operation" (file cannot be deleted) when win10 deletes a file
OpenGL Mosaic (8)
890. Find and Replace Pattern
Tongweb card, tongweb card, tongweb card
20 flowable container (event sub process, things, sub process, pool and pool)
SQL table columns and statements of database
随机推荐
redis
How to Algorithm Evaluation Methods
若依框架=》如何设置导入导出模板全局为文本格式(解决科学计数问题)
Pyqt5 module
Use of mongodb
OpenGL Mosaic (8)
2020 personal annual summary
MySQL basic query
Windbos common CMD (DOS) command set
19 calling subprocess (callactivity) of a flowable task
18 flowable task manualtask and receivetask
NVIDIA Jetson Nano/Xavier NX 扩容教程
MySQL log management and master-slave replication
MySQL table data modification
Calculate the number of days between two times (supports cross month and cross year)
Why do so many people hate a-spice
How to view tongweb logs correctly?
Summary of the 11th week of sophomore year
The 13th week of the second semester of sophomore year
Class conflicts caused by tongweb Enterprise Edition and embedded Edition