LeetCode
leetcode.com › problems › reverse-vowels-of-a-string
Reverse Vowels of a String - LeetCode
Reverse Vowels of a String - Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once.
AlgoMonster
algo.monster › liteproblems › 345
345. Reverse Vowels of a String - In-Depth Explanation
In-depth solution and explanation for LeetCode 345. Reverse Vowels of a String in Python, Java, C++ and more. Intuitions, example walk through, and complexity analysis. Better than official and forum solutions.
Videos
GitHub
github.com › doocs › leetcode › blob › main › solution › 0300-0399 › 0345.Reverse Vowels of a String › README_EN.md
leetcode/solution/0300-0399/0345.Reverse Vowels of a String/README_EN.md at main · doocs/leetcode
class Solution: def reverseVowels(self, s: str) -> str: vowels = "aeiouAEIOU" i, j = 0, len(s) - 1 cs = list(s) while i < j: while i < j and cs[i] not in vowels: i += 1 while i < j and cs[j] not in vowels: j -= 1 if i < j: cs[i], cs[j] = cs[j], cs[i] i, j = i + 1, j - 1 return "".join(cs) class Solution { public String reverseVowels(String s) { boolean[] vowels = new boolean[128]; for (char c : "aeiouAEIOU".toCharArray()) { vowels[c] = true; } char[] cs = s.toCharArray(); int i = 0, j = cs.length - 1; while (i < j) { while (i < j && !vowels[cs[i]]) { ++i; } while (i < j && !vowels[cs[j]]) { --j; } if (i < j) { char t = cs[i]; cs[i] = cs[j]; cs[j] = t; ++i; --j; } } return String.valueOf(cs); } }
Author doocs
WalkCCC
walkccc.me › LeetCode › problems › 345
345. Reverse Vowels of a String - LeetCode Solutions
LeetCode Solutions in C++23, Java, Python, MySQL, and TypeScript.
YouTube
youtube.com › kevin naughton jr.
Reverse Vowels of a String - YouTube
For business inquiries email partnerships@k2.codes Discord: bit.ly/K2-discord
Published September 30, 2019 Views 26K
LeetCode-in-Java
leetcode-in-java.github.io › src › main › java › g0301_0400 › s0345_reverse_vowels_of_a_string
LeetCode-in-Java | Java-based LeetCode algorithm problem solutions, regularly updated.
The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases. ... public class Solution { private boolean isVowel(char c) { return c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c == 'o' || c == 'O' || c == 'u' || c == 'U'; } public String reverseVowels(String str) { int i = 0; int j = str.length() - 1; char[] str1 = str.toCharArray(); while (i < j) { if (!isVowel(str1[i])) { i++; } else if (!isVowel(str1[j])) { j--; } else { // swapping char t = str1[i]; str1[i] = str1[j]; str1[j] = t; i++; j--; } } return String.copyValueOf(str1); } }
edSlash
edslash.com › home › leetcode challenge #345. reverse vowels of a string
LeetCode Challenge #345. Reverse Vowels of a String - edSlash
November 28, 2023 - 4. After swapping, just increase ‘ i ‘ by ( i++) decrease ( j – -) The loop continues until ‘i’ is incremented and ‘j’ is decremented to continue searching for other pairs of vowels. And it will run until ‘ i ‘ is no longer less than ‘j’ which means all the possible pairs or vowels have been swapped. 5. finally we will come outside the loop and the string ‘ s’ is returned .
LeetCode
leetcode.com › problems › reverse-vowels-of-a-string › solutions › 2484211 › reverse-vowels-of-a-string
Official Solution - Reverse Vowels of a String - LeetCode
View official solution of Reverse Vowels of a String on LeetCode, the world's largest programming community.