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.
public static int jumpingOnClouds(int[] c, int k)
{
int index = 0;
int points = 100;
bool isExit = false;
while (true)
{
index += k;
if (index > c.Length - 1)
{
index = index % c.Length;
isExit = true;
}
int value = c[index];
if (value == 1)
points -= 2;
points--;
if (index == 0 && isExit) break;
}
return points;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jumping on the Clouds: Revisited
You are viewing a single comment's thread. Return to all comments →
This is my solution in C# 😉