We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
s is being used to track the current number of consecutive ones.
t is being used to track the max. number of consecutive ones.
If you simply print s, it wil change in next iteration, and you will end-up printing multiple values. We need to print the final max value.
For example: 237 ==> 11101101.
Here:
s will change in sequence: 0, 1, 0, 1, 2, 0, 1, 2, 3
t will change in sequence: 0, 1, 1, 1, 2, 2, 2, 2, 3
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 10: Binary Numbers
You are viewing a single comment's thread. Return to all comments →
s is being used to track the current number of consecutive ones. t is being used to track the max. number of consecutive ones. If you simply print s, it wil change in next iteration, and you will end-up printing multiple values. We need to print the final max value. For example: 237 ==> 11101101. Here: s will change in sequence: 0, 1, 0, 1, 2, 0, 1, 2, 3 t will change in sequence: 0, 1, 1, 1, 2, 2, 2, 2, 3