LeetCode/Arrays 101
Leetcode. Find Numbers with Even Number of Digits
벤진[Benzene]
2020. 7. 1. 09:54
Problem:
Given an array nums of integers, return how many of them contain an even number of digits.

-Summary-
1. Format change int to string for each number and count the length of the str format of the number.
2. Check if it is even or odd number of digits.
class Solution:
def findNumbers(self, nums: List[int]) -> int:
count = 0
for num in nums:
if len(str(num)) % 2 == 0:
count += 1
return count
모든 문제에 대한 저작권은 LeetCode 회사에 있습니다. [Copyright © 2020 LeetCode]