#K69997. Minimum Jumps to End
Minimum Jumps to End
Minimum Jumps to End
You are given a series of platforms represented by a binary array of length \(N\). Each platform is either safe (denoted by 0) or unsafe (denoted by 1). Sakura starts at the first platform (index 0) and her goal is to reach the last platform (index \(N-1\)).
Sakura can jump either 1 step or 2 steps forward at a time, but she can only land on safe platforms. If either the starting or the ending platform is unsafe, or if it is impossible to reach the last platform due to unsafe platforms blocking all possible paths, the answer should be \(-1\). Otherwise, determine the minimum number of jumps required to reach the end.
Note: All input is read from standard input and output is written to standard output.
inputFormat
The first line contains a single integer \(N\) representing the number of platforms.
The second line contains \(N\) space-separated integers \(a_0, a_1, \ldots, a_{N-1}\) where each \(a_i\) is either 0 (safe) or 1 (unsafe).
outputFormat
Output a single integer that is the minimum number of jumps required to reach the last platform. If it is impossible, output \(-1\).
## sample5
0 0 1 0 0
3
</p>