File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 16
16
226|[ Invert Binary Tree] ( ./0226-invert-binary-tree.js ) |Easy|
17
17
263|[ Ugly Number] ( ./0263-ugly-number.js ) |Easy|
18
18
264|[ Ugly Number II] ( ./0264-ugly-number-ii.js ) |Medium|
19
+ 345|[ Reverse Vowels of a String] ( ./0345-reverse-vowels-of-a-string.js ) |Easy|
19
20
387|[ First Unique Character in a String] ( ./0387-first-unique-character-in-a-string.js ) |Easy|
20
21
451|[ Sort Characters By Frequency] ( ./0451-sort-characters-by-frequency.js ) |Medium|
21
22
459|[ Repeated Substring Pattern] ( ./0459-repeated-substring-pattern.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 345. Reverse Vowels of a String
3
+ * https://leetcode.com/problems/reverse-vowels-of-a-string/
4
+ * Difficulty: Easy
5
+ *
6
+ * Write a function that takes a string as input
7
+ * and reverse only the vowels of a string.
8
+ */
9
+
10
+ /**
11
+ * @param {string } s
12
+ * @return {string }
13
+ */
14
+ var reverseVowels = function ( s ) {
15
+ const vowels = s . match ( / [ a e i o u ] / ig) ;
16
+ return s . replace ( / [ a e i o u ] / ig, ( ) => vowels . pop ( ) ) ;
17
+ } ;
You can’t perform that action at this time.
0 commit comments