Sort by

recency

|

1013 Discussions

|

  • + 0 comments
    long strangeCounter(long t) {
        if(t==1)return 3;
        long start=1,multiply=3;
        while(start<=t){
            start+=multiply;
            multiply*=2;
        }
        //now certainly start >t i must find the slack
        return start-t;
    }
    
  • + 0 comments

    def strangeCounter(t):

    # Write your code here
    s = 1
    i = 3
    while (s < t):
        s += i
        i = i * 2
    if (s > t):
        return s - t
    return s - t + i
    
  • + 1 comment

    def strangeCounter(t): # Write your code here start_value = 3 value = start_value time = 1 while time < t: if t - time < value: if value == 1: value = start_value * 2 start_value = value time+=1 continue value-= t - time time+= t - time else: time += value value *= 2 return value

  • + 0 comments

    Here is problem solution in python, java, c++, c and javascript programming - https://programmingoneonone.com/hackerrank-strange-counter-problem-solution.html

  • + 0 comments

    long strangeCounter(long t) { long b = 1, tmp = 3, idx = 3, j; while (idx < t){ b += tmp; tmp *= 2; idx += tmp; } j = t - b + 1; return tmp - j + 1; } delray dermatology