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.
Strange Counter
Strange Counter
Sort by
recency
|
983 Discussions
|
Please Login in order to post a comment
Here is my c++ solution, you can watch the explanation here : https://youtu.be/Plsx1i8dqiI
C++ solution:
Java solution:
def strangeCounter(t): sm = 0 for i in range(10**12): sm += 2**i if 3*sm >= t: return 3*sm-t+1
This is the full steps of calculation: