In my first day in my new flat, I found that the doors of all flats are forming a straight line and all doors are equidistant from each another. At some doors there is a bomb with a timer. This timer indicates how many time units are remaining till the bomb explode. I called a fire-cracking company which and they told me that they have world class fire-cracking experts. Their experts can crack any bomb in 5 time units and move from one door to another in a single time unit. One expert can crack multiple bombs in sequence, not in parallel. We want to determine the minimum number of experts that we need to crack all the bombs. Write a function: int solution(int] doors) that, given a zero-indexed array $\boldsymbol{A}$ consisting of $N$ integers each integer indicates the time remaining till the bomb explode or -1 means there is no bomb on this door, returns an integer that represents the minimum number of experts needed to crack all bombs assuming that all the experts start at door in index 0 . If it's impossible to crack all bombs (no solution), return - 1 . Assume that: The length of array A is between [1, 1000] Example 1: Input: doors $=[5,-1,10]$ Output: 2

Public Answer

BPAC2V The First Answerer