• + 0 comments

    code in pyhton3

    binary_str = bin(n)[2:]
    
    target_no = "1"
    current_count = 0
    max_count = 0
    
    for x in binary_str:
        if x == target_no:
            current_count += 1
            if current_count>max_count:
                max_count = current_count
            else:
                max_count
        else:
            current_count = 0
    print(max_count)