• + 8 comments

    C# like most, but just transform the array to one of lengths and take max.

    static void Main(String[] args) {
        int n = Convert.ToInt32(Console.ReadLine());
        var b = Convert.ToString(n,2);
        string[] arr = b.Split('0').ToArray();
        int c = arr.Select(x => x.Length).Max();
        Console.WriteLine(c);
    }