Jumping on the Clouds: Revisited

  • + 0 comments

    int jumpingOnClouds(vector c, int k) { int e = 100; int position = 0; int n = c.size();

    while (true) {
        position = (position + k) % n;
        e -= 1;
        if (c[position] == 1)
            e -= 2;  // thundercloud
    
        cout << e << " " << position << " " << c[position] << endl;
    
        if (position == 0)
            break;
    }
    return e;
    

    }