43
4
Given an integer n > 0
, output the length of the longest contiguous sequence of 0
or 1
in its binary representation.
Examples
6
is written110
in binary; the longest sequence is11
, so we should return2
16
→10000
→4
893
→1101111101
→5
1337371
→101000110100000011011
→6
1
→1
→1
9965546
→100110000000111111101010
→7
8OEIS A043276 – alephalpha – 2017-01-13T04:45:25.197
Can we assume any bound of the size of the integer like 32 bit or 64 bit? – xnor – 2017-01-13T05:55:11.670
@xnor yes you can assume the int is 32 bits max – Arnaud – 2017-01-13T06:20:52.257