题目描述:
方法一:O(N)
class Solution: def findNumbers(self, nums: List[int]) -> int: ans=0 for num in nums: if len(str(num))%2==0: ans+=1 return ans
方法二:数学 O(N)
class Solution: def findNumbers(self, nums: List[int]) -> int: return sum(1 for num in nums if int(math.log10(num) + 1) % 2 == 0)
原文地址:https://www.cnblogs.com/oldby/p/12098477.html
时间: 2024-10-12 13:50:52