• + 0 comments

    python implementation

    def jumpingOnClouds(c):
        # Write your code here
        jumps = 0
        i=0
        c_len=len(c)
        while i < c_len - 1:
            j=2
            while j >0:
                if i+j<=c_len-1:
                    if c[i+j]==0:
                        i+=j
                        jumps+=1
                        break
                    else:
                        j-=1
                else:
                    j-=1
        return jumps