Sort by

recency

|

3285 Discussions

|

  • + 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
    
  • + 0 comments

    Solution i have tried::: Java

    public static int jumpingOnClouds(List<Integer> c) {
    // Write your code here
    int jump=0,temp=0,k=0;
    
           for(int j=k;j<c.size();j++){
    
         if( c.get(j)==0){
            temp++;
         }
        if (c.get(j)==1)
        {
            k=j;
             jump+=temp/2;
            temp=0;
            jump++;
    
    
        }
           }
    
             if (c.get(c.size()-1)==0 && c.get(c.size()-2)==0) {
               jump++;
           }
        return jump;
    }