Sort by

recency

|

3286 Discussions

|

  • + 0 comments

    C++

    int jumpingOnClouds(vector<int> &c) {
        int cnt = 0;
    
        for (int j = 0; j < c.size() - 1; j = j + 2) {
            if (c[j + 2] == 1) {
                j--;
                cnt++;
            } else { cnt++; }
        }
    
        return cnt;
    }
    
  • + 0 comments
    function jumpingOnClouds(c: number[]): number {
        let jumps = 0
        for(let i=0; i < c.length - 1; i++){
            const nextDoubleCloud = c[i + 2]
            if(nextDoubleCloud == 0) {
                i++
            }
            jumps++
        }
        return jumps
    }
    
  • + 0 comments

    Jumping on the Clouds sounds like such a fun and creative concept! Whether it's about tackling challenges or dreaming big, it's a reminder to aim high. Just like in life, though, it’s always smart to stay grounded while pursuing those big dreams. What’s the story behind this idea?

  • + 0 comments

    def jumpingOnClouds(c): # Write your code here cnt=0 i=0 while i+2

  • + 0 comments
    def jumpingOnClouds(c):
        # Write your code here
        
        jump_count = 0
        counter = 0
        n = len(c)
        while counter < (n - 1):
            if counter + 2 < n and c[counter + 2] == 0:
                counter += 2
            else:
                counter += 1
            jump_count += 1
        return jump_count