• + 0 comments

    Python : took time to fix a silly miss in step if binnum[i] == '1' .. missed quotes

    bin_num = ''
    temp_num = n
    while temp_num > 0:
        bin_num = str(temp_num % 2) + bin_num
        temp_num //= 2
    
    count = 0
    max_count = 0
    i=0
    for i in range(len(bin_num)):
        if bin_num[i] == '1':
            count += 1
            if count > max_count:
                max_count = count
        else:
            count = 0
    
    print(max(max_count, count))