본문 바로가기
python-algorithm

leetcode 3120. Count the Number of Special Characters I

by 무적김두칠 2024. 4. 21.

https://leetcode.com/problems/count-the-number-of-special-characters-i/description/

 

1
2
3
4
5
6
7
8
class Solution:
    def numberOfSpecialChars(self, word: str-> int:
        answer = 0
        for i in range(26):
            if chr(i + 97in word and chr(i + 97).upper() in word:
                answer += 1
        
        return answer
cs
반응형

'python-algorithm' 카테고리의 다른 글

leetcode 3110. Score of a String  (0) 2024.04.22
백준 27736 찬반투표  (0) 2024.04.21
백준 31668 특별한 가지  (0) 2024.04.19
백준 31428 엘리스 트랙 매칭  (0) 2024.04.19
백준 31520 Champernowne Verification  (0) 2024.04.18

댓글