题解 | #求最大连续bit数#
求最大连续bit数
http://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
Swift题解:
while let str = readLine(), let n = Int(str) {
let binary = String.init(n, radix: 2, uppercase: false)
let array = binary.components(separatedBy: "0").sorted { s1, s2 in
return s1.count < s2.count
}
let count = array.last?.count ?? 0
print(count)
}