Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int jumpingOnClouds(int c_count, int* c) {
- int i;
- int currentPosition=0;
- int safeJump=0;
- int jumpCount=0;
- while(currentPosition<c_count)
- {
- for(i=currentPosition+1;i<c_count;c++)
- {
- if(c[i]==0)
- {
- safeJump++;
- }
- else if (c[i]==1) {
- currentPosition+=safeJump;
- jumpCount+=safeJump;
- break;
- }
- else if (safeJump==2) {
- currentPosition+=safeJump;
- jumpCount+=safeJump;
- break;
- }
- }
- }
- return jumpCount;
- }
Add Comment
Please, Sign In to add comment