
[LeetCode] 345. Reverse Vowels of a String, Easy
·
CodingTest/LeetCode
1. 문제문자열 s가 주어질 때, 모음의 순서를 뒤집은 문자열을 반환하라IceCreAm의 모음 순서는 I, e, e, A => A, e, e, I로 뒤집어 바꾼 뒤 반환.2. 해결function reverseVowels(s: string): string { const vowels = [97, 101, 105, 111, 117]; const strVowels = []; for(const char of s) { if (vowels.includes(char.toLowerCase().charCodeAt(0))) { strVowels.push(char) } } strVowels.reverse(); const sArr = s..