HackerRank Solution: Jumping on clouds

Sakshi Singh
1 min readJun 28, 2019

--

In Python3

# Complete the jumpingOnClouds function below.

def jumpingOnClouds(c):

cnt=0

n = len(c)-1

i=0

while(i<n):

if(i+2<=n and c[i+2]==0):

i+=2

cnt+=1

elif(i+1<=n and c[i+1]==0):

i+=1

cnt+=1

return cnt

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Sakshi Singh
Sakshi Singh

Responses (1)

Write a response