File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 826
826
| 2696 | [Minimum String Length After Removing Substrings](https://leetcode.com/problems/minimum-string-length-after-removing-substrings) | [](src/MinimumStringLengthAfterRemovingSubstrings.java) | |
827
827
| 2697 | [Lexicographically Smallest Palindrome](https://leetcode.com/problems/lexicographically-smallest-palindrome) | [](src/LexicographicallySmallestPalindrome.java) | |
828
828
| 2706 | [Buy Two Chocolates](https://leetcode.com/problems/buy-two-chocolates) | [](src/BuyTwoChocolates.java) | |
829
- | 2710 | [Remove Trailing Zeros From a String](https://leetcode.com/problems/remove-trailing-zeros-from-a-string) | [](src/RemoveTrailingZerosFromAString.java) | |
830
- | 2716 | [Minimize String Length](https://leetcode.com/problems/minimize-string-length) | | |
829
+ | 2710 | [Remove Trailing Zeros From a String](https://leetcode.com/problems/remove-trailing-zeros-from-a-string) | [](src/RemoveTrailingZerosFromAString.java) | |
830
+ | 2716 | [Minimize String Length](https://leetcode.com/problems/minimize-string-length) | [](src/MinimizeStringLength.java) | |
831
831
| 2717 | [Semi-Ordered Permutation](https://leetcode.com/problems/semi-ordered-permutation) | | |
832
832
| 2728 | [Count Houses in a Circular Street](https://leetcode.com/problems/count-houses-in-a-circular-street) | | |
833
833
| 2729 | [Check if The Number is Fascinating](https://leetcode.com/problems/check-if-the-number-is-fascinating) | | |
Original file line number Diff line number Diff line change
1
+ // https://leetcode.com/problems/minimize-string-length
2
+ // T: O(N)
3
+ // S: O(1)
4
+
5
+ import java .util .HashSet ;
6
+ import java .util .Set ;
7
+
8
+ public class MinimizeStringLength {
9
+ public int minimizedStringLength (String s ) {
10
+ final Set <Character > letters = new HashSet <>();
11
+ for (int i = 0 ; i < s .length () ; i ++) {
12
+ letters .add (s .charAt (i ));
13
+ }
14
+ return letters .size ();
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments