From f0132435b01f1f88e564ff2663aed00d24137469 Mon Sep 17 00:00:00 2001 From: Thanh829 Date: Sat, 11 Dec 2021 11:58:19 +0700 Subject: [PATCH 01/10] Added task 345 --- .../Solution.java | 37 +++++++++++++++++++ .../readme.md | 24 ++++++++++++ .../SolutionTest.java | 18 +++++++++ 3 files changed, 79 insertions(+) create mode 100644 src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java create mode 100644 src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/readme.md create mode 100644 src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java diff --git a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java new file mode 100644 index 000000000..5438a925e --- /dev/null +++ b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java @@ -0,0 +1,37 @@ +package g0301_0400.s0345_reverse_vowels_of_a_string; + +class Solution { + static 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++; + continue; + } + if (!isVowel(str1[j])) { + j--; + continue; + } + + // swapping + char t = str1[i]; + str1[i] = str1[j]; + str1[j] = t; + + + i++; + j--; + } + return String.copyValueOf(str1); + + } +} \ No newline at end of file diff --git a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/readme.md b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/readme.md new file mode 100644 index 000000000..08c5a65df --- /dev/null +++ b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/readme.md @@ -0,0 +1,24 @@ +345\. Reverse Vowels of a String + +Easy + +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 cases. + +**Example 1:** + +**Input:** s = "hello" + +**Output:** "holle" + +**Example 2:** + +**Input:** s = "leetcode" + +**Output:** "leotcede" + +**Constraints:** + +* 1 <= s.length <= 3 * 105 +* `s` consist of **printable ASCII** characters. \ No newline at end of file diff --git a/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java b/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java new file mode 100644 index 000000000..2caf1de15 --- /dev/null +++ b/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java @@ -0,0 +1,18 @@ +package g0301_0400.s0345_reverse_vowels_of_a_string; + +import org.junit.jupiter.api.Test; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +class SolutionTest { + @Test + void reverseVowels() { + assertThat(new g0301_0400.s0345_reverse_vowels_of_a_string.Solution().reverseVowels("hello"), equalTo("holle")); + } + + @Test + void reverseVowels2() { + assertThat(new g0301_0400.s0345_reverse_vowels_of_a_string.Solution().reverseVowels("leetcode"), equalTo("leotcede")); + } +} From de5e81325b6747f6d4cb40f0c257487562f20d05 Mon Sep 17 00:00:00 2001 From: Thanh829 Date: Sat, 11 Dec 2021 13:40:33 +0700 Subject: [PATCH 02/10] update task 345, add task 349 --- .../Solution.java | 14 +++++------ .../Solution.java | 23 ++++++++++++++++++ .../readme.md | 24 +++++++++++++++++++ .../SolutionTest.java | 13 ++++++---- .../SolutionTest.java | 24 +++++++++++++++++++ 5 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java create mode 100644 src/main/java/g0301_0400/s0349_intersection_of_two_arrays/readme.md create mode 100644 src/test/java/g0301_0400/s0349_intersection_of_two_arrays/SolutionTest.java diff --git a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java index 5438a925e..41c93c078 100644 --- a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java +++ b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java @@ -1,11 +1,11 @@ package g0301_0400.s0345_reverse_vowels_of_a_string; -class Solution { +// #Easy #String #Two_Pointers + +public class Solution { static 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'); + 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) { @@ -27,11 +27,9 @@ public String reverseVowels(String str) { str1[i] = str1[j]; str1[j] = t; - i++; j--; } return String.copyValueOf(str1); - } -} \ No newline at end of file +} diff --git a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java new file mode 100644 index 000000000..f5a8a426a --- /dev/null +++ b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java @@ -0,0 +1,23 @@ +package g0301_0400.s0349_intersection_of_two_arrays; + +import java.util.ArrayList; +import java.util.List; + +// #Easy #Array #Hash_Table #Sorting #Binary_Search #Two_Pointers + +public class Solution { + public int[] intersection(int[] nums1, int[] nums2) { + List intersectionList = new ArrayList<>(); + + for (int j : nums1) { + for (int k : nums2) { + if (j == k && !intersectionList.contains(j)) { + intersectionList.add(j); + } + } + } + int[] result = new int[intersectionList.size()]; + for (int i = 0; i < intersectionList.size(); i++) result[i] = intersectionList.get(i); + return result; + } +} diff --git a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/readme.md b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/readme.md new file mode 100644 index 000000000..4e749bb4d --- /dev/null +++ b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/readme.md @@ -0,0 +1,24 @@ +349\. Intersection of Two Arrays + +Easy + +Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must be **unique** and you may return the result in **any order**. + +**Example 1:** + +**Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\] + +**Output:** \[2\] + +**Example 2:** + +**Input:** nums1 = \[4,9,5\], nums2 = \[9,4,9,8,4\] + +**Output:** \[9,4\] + +**Explanation:** \[4,9\] is also accepted. + +**Constraints:** + +* `1 <= nums1.length, nums2.length <= 1000` +* `0 <= nums1[i], nums2[i] <= 1000` \ No newline at end of file diff --git a/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java b/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java index 2caf1de15..70ee435c9 100644 --- a/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java +++ b/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java @@ -1,18 +1,23 @@ package g0301_0400.s0345_reverse_vowels_of_a_string; -import org.junit.jupiter.api.Test; - import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.jupiter.api.Test; + class SolutionTest { @Test void reverseVowels() { - assertThat(new g0301_0400.s0345_reverse_vowels_of_a_string.Solution().reverseVowels("hello"), equalTo("holle")); + assertThat( + new g0301_0400.s0345_reverse_vowels_of_a_string.Solution().reverseVowels("hello"), + equalTo("holle")); } @Test void reverseVowels2() { - assertThat(new g0301_0400.s0345_reverse_vowels_of_a_string.Solution().reverseVowels("leetcode"), equalTo("leotcede")); + assertThat( + new g0301_0400.s0345_reverse_vowels_of_a_string.Solution() + .reverseVowels("leetcode"), + equalTo("leotcede")); } } diff --git a/src/test/java/g0301_0400/s0349_intersection_of_two_arrays/SolutionTest.java b/src/test/java/g0301_0400/s0349_intersection_of_two_arrays/SolutionTest.java new file mode 100644 index 000000000..26ab85f9a --- /dev/null +++ b/src/test/java/g0301_0400/s0349_intersection_of_two_arrays/SolutionTest.java @@ -0,0 +1,24 @@ +package g0301_0400.s0349_intersection_of_two_arrays; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void intersection() { + assertThat( + new g0301_0400.s0349_intersection_of_two_arrays.Solution() + .intersection(new int[] {1, 2, 2, 1}, new int[] {2, 2}), + equalTo(new int[] {2})); + } + + @Test + void intersection2() { + assertThat( + new g0301_0400.s0349_intersection_of_two_arrays.Solution() + .intersection(new int[] {4, 9, 5}, new int[] {9, 4, 9, 8, 4}), + equalTo(new int[] {4, 9})); + } +} From 9ac2472885eab292571fa31c1a139e904220c185 Mon Sep 17 00:00:00 2001 From: Thanh829 Date: Sat, 11 Dec 2021 14:28:07 +0700 Subject: [PATCH 03/10] fix comments --- .../s0349_intersection_of_two_arrays/Solution.java | 6 +++++- .../s0345_reverse_vowels_of_a_string/SolutionTest.java | 9 ++------- .../s0349_intersection_of_two_arrays/SolutionTest.java | 6 ++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java index f5a8a426a..5ae35d9f1 100644 --- a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java +++ b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java @@ -17,7 +17,11 @@ public int[] intersection(int[] nums1, int[] nums2) { } } int[] result = new int[intersectionList.size()]; - for (int i = 0; i < intersectionList.size(); i++) result[i] = intersectionList.get(i); + + for (int i = 0; i < intersectionList.size(); i++) { + result[i] = intersectionList.get(i); + } + return result; } } diff --git a/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java b/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java index 70ee435c9..6b9862e3a 100644 --- a/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java +++ b/src/test/java/g0301_0400/s0345_reverse_vowels_of_a_string/SolutionTest.java @@ -8,16 +8,11 @@ class SolutionTest { @Test void reverseVowels() { - assertThat( - new g0301_0400.s0345_reverse_vowels_of_a_string.Solution().reverseVowels("hello"), - equalTo("holle")); + assertThat(new Solution().reverseVowels("hello"), equalTo("holle")); } @Test void reverseVowels2() { - assertThat( - new g0301_0400.s0345_reverse_vowels_of_a_string.Solution() - .reverseVowels("leetcode"), - equalTo("leotcede")); + assertThat(new Solution().reverseVowels("leetcode"), equalTo("leotcede")); } } diff --git a/src/test/java/g0301_0400/s0349_intersection_of_two_arrays/SolutionTest.java b/src/test/java/g0301_0400/s0349_intersection_of_two_arrays/SolutionTest.java index 26ab85f9a..80ee11d17 100644 --- a/src/test/java/g0301_0400/s0349_intersection_of_two_arrays/SolutionTest.java +++ b/src/test/java/g0301_0400/s0349_intersection_of_two_arrays/SolutionTest.java @@ -9,16 +9,14 @@ class SolutionTest { @Test void intersection() { assertThat( - new g0301_0400.s0349_intersection_of_two_arrays.Solution() - .intersection(new int[] {1, 2, 2, 1}, new int[] {2, 2}), + new Solution().intersection(new int[] {1, 2, 2, 1}, new int[] {2, 2}), equalTo(new int[] {2})); } @Test void intersection2() { assertThat( - new g0301_0400.s0349_intersection_of_two_arrays.Solution() - .intersection(new int[] {4, 9, 5}, new int[] {9, 4, 9, 8, 4}), + new Solution().intersection(new int[] {4, 9, 5}, new int[] {9, 4, 9, 8, 4}), equalTo(new int[] {4, 9})); } } From 4d1914823ea23af56030f6d7b54b9a1d9b4a590a Mon Sep 17 00:00:00 2001 From: Thanh829 Date: Sat, 11 Dec 2021 22:08:01 +0700 Subject: [PATCH 04/10] update solution for task 345 and 349 --- .../Solution.java | 48 +++++++++---------- .../Solution.java | 26 +++++----- .../SolutionTest.java | 2 +- 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java index 41c93c078..0c52b8afd 100644 --- a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java +++ b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java @@ -2,34 +2,34 @@ // #Easy #String #Two_Pointers -public class Solution { - static 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'); +class Solution { + private boolean isVowel(char c) { + return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' + || c == 'A' || c == 'E' || c == 'I' || c == 'O' || 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++; - continue; + private StringBuilder swap(StringBuilder s, int l, int r) { + char tmp = s.charAt(l); + s.setCharAt(l, s.charAt(r)); + s.setCharAt(r, tmp); + return s; + } + + public String reverseVowels(String s) { + int l = 0; + int r = s.length() - 1; + StringBuilder res = new StringBuilder(s); + while (l < r) { + while (l < r && !isVowel(s.charAt(l))) { + l++; } - if (!isVowel(str1[j])) { - j--; - continue; + while (l < r && !isVowel(s.charAt(r))) { + r--; } - - // swapping - char t = str1[i]; - str1[i] = str1[j]; - str1[j] = t; - - i++; - j--; + res = swap(res, l, r); + l++; + r--; } - return String.copyValueOf(str1); + return res.toString(); } } diff --git a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java index 5ae35d9f1..d3b25df75 100644 --- a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java +++ b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java @@ -5,23 +5,19 @@ // #Easy #Array #Hash_Table #Sorting #Binary_Search #Two_Pointers -public class Solution { +class Solution { public int[] intersection(int[] nums1, int[] nums2) { - List intersectionList = new ArrayList<>(); - - for (int j : nums1) { - for (int k : nums2) { - if (j == k && !intersectionList.contains(j)) { - intersectionList.add(j); - } + boolean occ[]=new boolean[1001]; + for(int i=0;i res=new ArrayList<>(); + for(int i=0;i Date: Sat, 11 Dec 2021 22:22:34 +0700 Subject: [PATCH 05/10] fix comment --- .../g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java index 0c52b8afd..6eaf3b8c3 100644 --- a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java +++ b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java @@ -2,7 +2,7 @@ // #Easy #String #Two_Pointers -class Solution { +public class Solution { private boolean isVowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'; From 223285542773e1ced82d9e30bdaa4726adff7311 Mon Sep 17 00:00:00 2001 From: ThanhNIT Date: Sat, 11 Dec 2021 22:27:37 +0700 Subject: [PATCH 06/10] format code --- .../Solution.java | 4 ++-- .../Solution.java | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java index 6eaf3b8c3..8630fd9c4 100644 --- a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java +++ b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java @@ -4,8 +4,8 @@ public class Solution { private boolean isVowel(char c) { - return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' - || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'; + return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' + || c == 'I' || c == 'O' || c == 'U'; } private StringBuilder swap(StringBuilder s, int l, int r) { diff --git a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java index d3b25df75..3937012a6 100644 --- a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java +++ b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java @@ -7,17 +7,17 @@ class Solution { public int[] intersection(int[] nums1, int[] nums2) { - boolean occ[]=new boolean[1001]; - for(int i=0;i res=new ArrayList<>(); - for(int i=0;i res = new ArrayList<>(); + for (int i = 0; i < nums2.length; i++) { + if (occ[nums2[i]]) { + occ[nums2[i]] = false; res.add(nums2[i]); } } - int result[]=new int[res.size()]; - for(int i=0;i Date: Sat, 11 Dec 2021 22:32:11 +0700 Subject: [PATCH 07/10] Update Solution.java --- .../g0301_0400/s0349_intersection_of_two_arrays/Solution.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java index 3937012a6..1160705ea 100644 --- a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java +++ b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java @@ -1,10 +1,10 @@ package g0301_0400.s0349_intersection_of_two_arrays; +// #Easy #Array #Hash_Table #Sorting #Binary_Search #Two_Pointers + import java.util.ArrayList; import java.util.List; -// #Easy #Array #Hash_Table #Sorting #Binary_Search #Two_Pointers - class Solution { public int[] intersection(int[] nums1, int[] nums2) { boolean occ[] = new boolean[1001]; From fb87b97551615a53d296551ceb4c6d4f1bd4b3b7 Mon Sep 17 00:00:00 2001 From: ThanhNIT Date: Sat, 11 Dec 2021 22:36:48 +0700 Subject: [PATCH 08/10] format code --- .../s0349_intersection_of_two_arrays/Solution.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java index 1160705ea..79e42a263 100644 --- a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java +++ b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java @@ -8,7 +8,9 @@ class Solution { public int[] intersection(int[] nums1, int[] nums2) { boolean occ[] = new boolean[1001]; - for (int i = 0; i < nums1.length; i++) occ[nums1[i]] = true; + for (int i = 0; i < nums1.length; i++) { + occ[nums1[i]] = true; + } List res = new ArrayList<>(); for (int i = 0; i < nums2.length; i++) { if (occ[nums2[i]]) { @@ -17,7 +19,9 @@ public int[] intersection(int[] nums1, int[] nums2) { } } int result[] = new int[res.size()]; - for (int i = 0; i < res.size(); i++) result[i] = res.get(i); + for (int i = 0; i < res.size(); i++) { + result[i] = res.get(i); + } return result; } } From eef5bc547ede107dd9c290586a1ce367afcfb46e Mon Sep 17 00:00:00 2001 From: ThanhNIT Date: Sat, 11 Dec 2021 22:38:40 +0700 Subject: [PATCH 09/10] Update Solution.java --- .../g0301_0400/s0349_intersection_of_two_arrays/Solution.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java index 79e42a263..bc3a190a5 100644 --- a/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java +++ b/src/main/java/g0301_0400/s0349_intersection_of_two_arrays/Solution.java @@ -7,7 +7,7 @@ class Solution { public int[] intersection(int[] nums1, int[] nums2) { - boolean occ[] = new boolean[1001]; + boolean[] occ = new boolean[1001]; for (int i = 0; i < nums1.length; i++) { occ[nums1[i]] = true; } @@ -18,7 +18,7 @@ public int[] intersection(int[] nums1, int[] nums2) { res.add(nums2[i]); } } - int result[] = new int[res.size()]; + int[] result = new int[res.size()]; for (int i = 0; i < res.size(); i++) { result[i] = res.get(i); } From d8af2d42562d46c101dca80672747e9a5fc4581e Mon Sep 17 00:00:00 2001 From: ThanhNIT Date: Sat, 11 Dec 2021 22:47:00 +0700 Subject: [PATCH 10/10] Update Solution.java --- .../g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java index 8630fd9c4..17ec197d9 100644 --- a/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java +++ b/src/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java @@ -26,7 +26,7 @@ public String reverseVowels(String s) { while (l < r && !isVowel(s.charAt(r))) { r--; } - res = swap(res, l, r); + swap(res, l, r); l++; r--; }