You are viewing a single comment's thread. Return to all comments →
Thanks You, I got this solution. I didn't think deep enough
static long strangeCounter(long t) { int i = 1; int rate = 3; while (i + rate <= t) { i = i + rate; rate = rate * 2; } return rate - t + i; }
After Improve my code from your code
static long strangeCounter(long t) { int rate = 3; while (t > rate) { t = t - rate; rate = rate * 2; } return rate - t + 1; }
I still cannot pass the time cases
Seems like cookies are disabled on this browser, please enable them to open this website
Strange Counter
You are viewing a single comment's thread. Return to all comments →
Thanks You, I got this solution. I didn't think deep enough
After Improve my code from your code
I still cannot pass the time cases