You are viewing a single comment's thread. Return to all comments →
It can be done in O(1) like this
long strangeCounter(long t) {
long n = ceil(log((t+3)/3.0)/log(2)); return 6*pow(2, n-1) - t -2;
}
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 →
It can be done in O(1) like this
long strangeCounter(long t) {
}