• + 0 comments

    give me your opinion please i need it

        public static int jumpingOnClouds(List<Integer> c) {
            if (c.isEmpty() || c.size() < 2) return 0;
            if (c.get(c.size() - 1) != 0) return 0;
            int jumpsRequired = 0;
            int i = 0;
            while (i < c.size() - 1) {
                if ((i + 1 < c.size() && c.get(i + 1) == 1) && (i + 2 < c.size() && c.get(i + 2) == 1)) {
                    break;
                }
                int next = i + 1;
                int afterNext = next + 1;
                if (afterNext < c.size() && c.get(afterNext) == 0) {
                    i = afterNext;
                    jumpsRequired++;
                } else if (next < c.size() && c.get(next) == 0) {
                    i = next;
                    jumpsRequired++;
                }
            }
            return jumpsRequired;
        }