Leetcode 345. Reverse Vowels of a String
来源:互联网 发布:爱淘宝天猫购物券口令 编辑:程序博客网 时间:2024/06/05 05:25
public class Solution { public String reverseVowels(String s) { HashSet<Character> hs = new HashSet<>(); hs.add('a'); hs.add('e'); hs.add('i'); hs.add('o'); hs.add('u'); hs.add('A'); hs.add('E'); hs.add('I'); hs.add('O'); hs.add('U'); int low = 0, high = s.length()-1; StringBuilder sb = new StringBuilder(s); while (low < high) { while (low < high && !hs.contains(sb.charAt(low))) low++; while (low < high && !hs.contains(sb.charAt(high))) high--; // swap low and high char tmp = sb.charAt(low); sb.setCharAt(low, sb.charAt(high)); sb.setCharAt(high, tmp); low++; high--; } return sb.toString(); }}
0 0
- LeetCode 345. Reverse Vowels of a String
- leetcode-345. Reverse Vowels of a String
- #leetcode#345. Reverse Vowels of a String
- [leetcode] 345. Reverse Vowels of a String
- Leetcode:345. Reverse Vowels of a String
- LeetCode *** 345. Reverse Vowels of a String
- LeetCode.345. Reverse Vowels of a String
- LeetCode 345. Reverse Vowels of a String
- Leetcode 345. Reverse Vowels of a String
- LeetCode 345. Reverse Vowels of a String
- 345.[LeetCode]Reverse Vowels of a String
- Leetcode 345. Reverse Vowels of a String
- LeetCode 345. Reverse Vowels of a String
- leetcode 345. Reverse Vowels of a String
- 【leetcode】345. Reverse Vowels of a String
- LeetCode-345.Reverse Vowels of a String
- LeetCode - 345. Reverse Vowels of a String
- [Leetcode]345. Reverse Vowels of a String
- 1082. Read Number in Chinese (25) PAT甲级
- [RTL综合]综合时保持RTL中直接写入的cell的层级
- scp简单使用
- poj1795(状态压缩dp,字符串压缩求最小字典序)
- NYOJ599 - 奋斗的小蜗牛
- Leetcode 345. Reverse Vowels of a String
- Leetcode 43. Multiply Strings
- 模拟栈的出入 HDOJ 1022 Train Problem I
- Spring 的aop实现原理
- PLSQL游标的使用
- Educational Codeforces Round 17 A+B
- SuperSocket入门(五)-常用协议实现模版及FixedSizeReceiveFilter示例_0
- C语言经典弱智问题解法整理
- dk uma creator 添加装备教程