Created
November 11, 2025 14:44
-
-
Save Shaddyjr/07d39d34700c80c8faf916bb3fa83f13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Source: https://www.hackerrank.com/challenges/strange-code/problem | |
| # Video: https://youtu.be/12nt1BhS4r4 | |
| def strangeCounter(t): | |
| # keep running time | |
| # interate for each max value | |
| current_max_val = 3 # always 3 | |
| while t > current_max_val: | |
| # there's still a whole group of current_max_val to skip | |
| t -= current_max_val | |
| current_max_val <<= 1 | |
| return current_max_val - t + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment