본문 바로가기
python-algorithm

leetcode 2716. Minimize String Length

by 무적김두칠 2023. 6. 27.

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

중복된 문자열을 제거 한 후 남은 알파벳의 개수를 세면 됩니다

반응형

댓글