Skip to content

Instantly share code, notes, and snippets.

@bugrym
Created February 21, 2020 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bugrym/7aca12d1ccbef21b2b74892450bbfce2 to your computer and use it in GitHub Desktop.
Save bugrym/7aca12d1ccbef21b2b74892450bbfce2 to your computer and use it in GitHub Desktop.
1295. Find Numbers with Even Number of Digits
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