1295. Find Numbers with Even Number of Digits

Doyeon Kim·2022년 12월 11일

코딩테스트 공부

목록 보기
151/171

문제 링크 : https://leetcode.com/problems/find-numbers-with-even-number-of-digits/description/


주어진 숫자들중 자리수가 짝수인 것의 개수를 반환하는 문제이다

주어진 숫자들을 문자열str로 치환환 뒤 개수가 짝수면 count해주면 되는 문제였다

class Solution:
    def findNumbers(self, nums: List[int]) -> int:
        cnt = 0
        for i in nums:
            if len(str(i)) %2 == 0:
                cnt+=1
        return cnt
profile
성장하고 도전하는 개발자. 프로그래밍 좋아하세요?

0개의 댓글