• + 0 comments

    Solution for c#

    public static int jumpingOnClouds(List<int> c)
        {
            int jumpCount = 0;
            int zeroCount = 0;
            
            for (int x = 0; x < c.Count; x++) {
               if (c[x] == 0) {
                   zeroCount++;
                   
                   if (x == c.Count -1) {
                        int quotient = (int)(zeroCount / 2);
                        jumpCount = jumpCount + quotient;
                   }
               } else if (c[x] > 0 || x == c.Count -1) {
                   int quotient = (int)(zeroCount / 2) + 1;
                   jumpCount = jumpCount + quotient;
                   
                   zeroCount = 0;
               }
            }
            return jumpCount;
        }