We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Jumping on the Clouds: Revisited
Jumping on the Clouds: Revisited
Sort by
recency
|
1184 Discussions
|
Please Login in order to post a comment
Here is my c++ solution, you can watch the explanation here : https://youtu.be/retgbr5jSsg
Here's a C solution: int jumpingOnClouds(int c_count, int* c, int k) { int e = 100, i=0, beg = c[0], end = -1; c[0] = 111;
while(end!=111){ if(c[i]==1){ e = e-2; } e--; if((i+k)>c_count-1) {
i = abs(i+k-c_count); } else{ i+=k; }
end = c[i]; } if(beg == 1){ e-=2; } return e; }
Here's a C# solution:
Perl solution:
Java 8 Code
// Complete the jumpingOnClouds function below.