Skip to content

Instantly share code, notes, and snippets.

@paulofaria
Created September 1, 2016 20:31
Show Gist options
  • Save paulofaria/778140bd5417f3f55cc3e40d5e9e9088 to your computer and use it in GitHub Desktop.
Save paulofaria/778140bd5417f3f55cc3e40d5e9e9088 to your computer and use it in GitHub Desktop.
public func solution(N : Int) -> Int {
let bytes = String(N, radix: 2)
var max = 0
var current = 0
for n in bytes.characters {
if n == "0" {
current += 1
} else {
if current > max {
max = current
}
current = 0
}
}
return max
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment