Jumping on the Clouds: Revisited

Sort by

recency

|

1203 Discussions

|

  • + 0 comments
    int jumpingOnClouds(vector<int> c, int k) {
        int energy = 100;
        int idx = 0;
        
        do {
            idx = (idx + k) % c.size();
            energy--;
            
            if (c[idx] == 1) energy -= 2;
        } while (idx != 0);
        
        return energy;
    }
    
  • + 0 comments

    It’s an engaging and uplifting piece that leaves a lasting impression. www.betbhai9.red

  • + 0 comments

    is there a mistake in constraints? they say n % k =0 and test case 8 doesn't follow it

    input:

    10 3

    1 1 1 0 1 1 0 0 0 0

  • + 0 comments

    this is so badly written it is almost embarassing

  • + 0 comments

    Python3 Solution

    def jumpingOnClouds(c, k):
        energy = 100
        
        isStarted = True
        idx = 0
        while True:
            if idx == 0:
                if isStarted:
                    isStarted = False
                else:
                    break
            
            idx = (idx+k)%len(c)
            energy -= 1
            if c[idx] == 1:
                energy -= 2
    
        return energy