You are viewing a single comment's thread. Return to all comments →
if __name__ == '__main__': n = int(input().strip()) bin_number = str(int(bin(n)[2:])) count = 0 max_ls = 0 for i in range(0, len(str(bin_number))): if bin_number[i] == '1': count +=1 if max_ls < count: max_ls= count elif bin_number[i] == '0': count = 0 if count > max_ls: print(count) else: print(max_ls)
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Day 10: Binary Numbers
You are viewing a single comment's thread. Return to all comments →