[LeetCode] 리트코드 1295번 Find Numbers with Even Number of Digits
(Python)
(글쓴날 : 2020.03.11)
* LeetCode, 리트코드 1295번 문제 Python 언어 풀이입니다.
* 소스 코드의 저작권은 글쓴이에게 있습니다.
리트코드 1295번 Find Numbers with Even Number of Digits
1) 문제
문제 링크 : https://leetcode.com/problems/find-numbers-with-even-number-of-digits/
Find Numbers with Even Number of Digits - LeetCode
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
2) 풀이 과정
배열(Python의 경우 리스트)에 속한 숫자들의 자릿수가 짝수인 개수를 구하는 문제입니다.
저의 경우, 각 숫자들을 문자열로 형변환한 후 길이를 구하여 짝수인 것 들의 개수를 구하였습니다.
3) 코드
* Python 코드
1
2
3
4
5
6
7
8
9
|
class Solution:
def findNumbers(self, nums: List[int]) -> int:
count = 0
for i in nums:
if len(str(i)) % 2 == 0:
count += 1
return count
|
'Deprecated' 카테고리의 다른 글
[CSS] CSS 초기화(Reset) 코드 모음 (0) | 2020.03.12 |
---|---|
[LeetCode] 리트코드 1266번 Minimum Time Visiting All Points(Python) (0) | 2020.03.11 |
[LeetCode] 리트코드 1108번 Defanging an IP Address(Python) (0) | 2020.03.11 |
[Baekjoon Online Judge] 백준 5543번 상근날드(Python) (0) | 2020.03.10 |
[styled-components] styled-components 소개 및 설치 방법 (0) | 2020.03.10 |