본문 바로가기
python-algorithm

leetcode 1941. Check if All Characters Have Equal Number of Occurrences

by 무적김두칠 2024. 2. 17.

https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences/description/

 

LeetCode - The World's Leading Online Programming Learning Platform

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

1
2
3
4
5
6
7
8
9
class Solution:
    def areOccurrencesEqual(self, s: str-> bool:
        check_list = list(set(list(s)))
        for i in range(len(check_list) - 1):
            if s.count(check_list[i]) != s.count(check_list[i - 1]):
                return False
        
        return True
        
cs
반응형

댓글