Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function jumpingOnClouds(c, k) {
let index = 0;
let energy = 100;
let stop = false;
while (!stop) {
if (c[index] === 1) {
energy -= 2;
}
energy -= 1;
index = (index + k) % c.length;
if (index === 0) {
stop = true;
}
}
return energy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment