Reverse Vowels of a String 交换元音字母
来源:互联网 发布:企业电话查询软件 编辑:程序博客网 时间:2024/05/21 01:44
题目要求:
Write a function that takes a string as input and reverse only the vowels of a string.
Example 1:
Given s = "hello", return "holle".
Example 2:
Given s = "leetcode", return "leotcede".
Subscribe to see which companies asked this question
public static String reverseVowels(String s) { char[] st=s.toCharArray(); String vowels = "aeiouAEIOU"; int i=0; int j=st.length-1; while(i<j) { while(i<j && !vowels.contains(st[i]+"")) {i++;} while(i<j && !vowels.contains(st[j]+"")) {j--;} char temp=st[i];st[i]=st[j];st[j]=temp; i++;j--; } return new String(st); }
0 0
- Reverse Vowels of a String 交换元音字母
- 逆转字符串中的元音字母 Reverse Vowels of a String
- 【leetcode80】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. Reverse Vowels of a String (转置字符串中的元音字母)
- 345. Reverse Vowels of a String | 逆置字符串中的元音字母
- 【leetcode】 Reverse Vowels of a String(翻转字符串中出现的元音字母)
- Reverse Vowels of a String -- 颠倒字符串中的元音
- Reverse Vowels of a String 仅翻转元音字符
- Reverse Vowels of a String
- Reverse Vowels of a String
- Reverse Vowels of a String
- Reverse Vowels of a String
- Reverse Vowels of a String
- Reverse Vowels of a String
- Reverse Vowels of a String
- 底部弹出框
- JSON.parse()和JSON.stringify()
- 使用递归进行插入排序
- 有容云AppSoar容器健康检查与调度策略
- 使程序在Linux下后台运行 (关掉终端继续让程序运行的方法)
- Reverse Vowels of a String 交换元音字母
- 一个Windows 系统究竟有多复杂?
- jxl和POI的区别
- networkx库:AttributeError: 'module' object has no attribute 'graphviz_layout'
- n个骰子的点数和
- 理解Javascript中的Function
- Hive外部表学习
- CSS基础学习
- CocoaPods忽略更新版本