Created
February 21, 2020 09:26
-
-
Save bugrym/7aca12d1ccbef21b2b74892450bbfce2 to your computer and use it in GitHub Desktop.
1295. Find Numbers with Even Number of Digits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func findNumbers(_ nums: [Int]) -> Int { | |
var res = 0 | |
if nums.count >= 1 && nums.count <= 500 { | |
nums.map { | |
if $0 >= 1 && $0 <= 100000 { | |
var givenNum = $0 | |
var digits:[Int] = [] | |
repeat { | |
let num = givenNum%10 | |
givenNum/=10 | |
digits.append(num) | |
} while (givenNum != 0) | |
if digits.count%2 == 0 { | |
res += 1 | |
} | |
} | |
} | |
} | |
return res | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment