Created
September 1, 2016 20:31
-
-
Save paulofaria/778140bd5417f3f55cc3e40d5e9e9088 to your computer and use it in GitHub Desktop.
This file contains 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
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