https://leetcode.com/problems/minimize-string-length/description/
Minimize String Length - LeetCode
Can you solve this real interview question? Minimize String Length - Given a 0-indexed string s, repeatedly perform the following operation any number of times: * Choose an index i in the string, and let c be the character in position i. Delete the closest
leetcode.com
1
2
3
4
5
|
class Solution:
def minimizedStringLength(self, s: str) -> int:
set_s = list(set([i for i in s]))
return len(set_s)
|
cs |
중복된 문자열을 제거 한 후 남은 알파벳의 개수를 세면 됩니다
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2544. Alternating Digit Sum (0) | 2023.07.03 |
---|---|
leetcode 2595. Number of Even and Odd Bits (0) | 2023.06.27 |
leetcode 2710. Remove Trailing Zeros From a String (0) | 2023.06.26 |
leetcode 2656. Maximum Sum With Exactly K Elements (0) | 2023.06.26 |
leetcode 35. Search Insert Position (0) | 2023.06.26 |
댓글