I'm doing practice coding on HackerRank and I was having trouble with one of the problems. I looked at how others would handle it and came across something I haven't seen before.
public static int jumpingOnClouds(List<int> c)
{
int count = 0;
for (int i = 0; i < c.Count - 1; i++)
{
if (c[i] == 0)
i++;
count++;
}
return count;
}
This iteration is supposed to go through an array of integers. It the integer is 0 it takes a step and if it's 1 it does nothing. At the "if" statement it goes:
if (c[i] == 0)
i++;
count++;
And this code works. However I tried rewriting it like this:
if (c[i] == 0)
{
i++;
count++;
}
But it doesn't work the way the previous code did. Can someone help and explain what this person did because I'm not sure where to look or what this is even called?