File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
main/java/com/fishercoder/solutions
test/java/com/fishercoder Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
8
8
9
9
| # | Title | Solutions | Video | Difficulty | Tag
10
10
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|----------------------------------|-------------
11
+ | 2716 |[Minimize String Length](https://leetcode.com/problems/minimize-string-length/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2716.java) | | Easy |
11
12
| 2710 |[Remove Trailing Zeros From a String](https://leetcode.com/problems/remove-trailing-zeros-from-a-string/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2710.java) | | Easy |
12
13
| 2706 |[Buy Two Chocolates](https://leetcode.com/problems/buy-two-chocolates/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2706.java) | | Easy |
13
14
| 2696 |[Minimum String Length After Removing Substrings](https://leetcode.com/problems/minimum-string-length-after-removing-substrings/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2696.java) | | Easy |
Original file line number Diff line number Diff line change
1
+ package com .fishercoder .solutions ;
2
+
3
+ import java .util .HashSet ;
4
+ import java .util .Set ;
5
+
6
+ public class _2716 {
7
+ public static class Solution1 {
8
+ public int minimizedStringLength (String s ) {
9
+ StringBuilder sb = new StringBuilder ();
10
+ Set <Character > set = new HashSet <>();
11
+ for (int i = 0 ; i < s .length (); i ++) {
12
+ if (set .add (s .charAt (i ))) {
13
+ sb .append (s .charAt (i ));
14
+ }
15
+ }
16
+ return sb .length ();
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ package com .fishercoder ;
2
+
3
+ import com .fishercoder .solutions ._2716 ;
4
+ import org .junit .BeforeClass ;
5
+ import org .junit .Test ;
6
+
7
+ import static org .junit .Assert .assertEquals ;
8
+
9
+ public class _2716Test {
10
+ private static _2716 .Solution1 solution1 ;
11
+
12
+ @ BeforeClass
13
+ public static void setup () {
14
+ solution1 = new _2716 .Solution1 ();
15
+ }
16
+
17
+ @ Test
18
+ public void test1 () {
19
+ assertEquals (2 , solution1 .minimizedStringLength ("ipi" ));
20
+ }
21
+
22
+ }
You can’t perform that action at this time.
0 commit comments