Jumping on the Clouds: Revisited

  • + 0 comments

    Here is my C# solution The do while loop help in continueing the traversal until the initial point is reached and making the initial jump.

        static int jumpingOnClouds(int[] c, int k) 
        {
            int e =100;
            int n = c.Count();
            int i =0;
            do{
                i = (i+k)%n;
                e--;
                if(c[i]==1)
                    e-=2;     
            }while(i!=0);
            return e;
        }