Leetcode Note: Go - Find Numbers With Even Number of Digits
Find Numbers with Even Number of Digits - LeetCode
https://leetcode.com/problems/find-numbers-with-even-number-of-digits/
- Go 言語で取り組んだメモ
回答
Funny with Go - Find Numbers with Even Number of Digits - LeetCode
https://leetcode.com/problems/find-numbers-with-even-number-of-digits/solutions/2466927/funny-with-go/
func findNumbers(nums []int) int {
isEven := func(num int) bool {
count := 0
for num > 0 {
count++
num /= 10
}
return count % 2 == 0
}
count := 0
for _, num := range nums {
if isEven(num) {
count++
}
}
return count
}