Company: THOUGHT WORKS
Difficulty: medium
Problem Statement A farmer planted crops in a field and observed variations in plant heights. To assess the overall growth, he devised a formula. Given a row of plants, represented by an array crop , where each element crop[i] denotes the height of the plant at position i , find if the crop is growing well. The conditions for well growing crops are as follows: i > 1 |i - j| ≤ position |crop[i] - crop[j]| ≤ height Note: If valid, reply 1 means crop is growing well. The negative value in crop[i] indicates undergrowth. Input Format The first line of input contains an integer position. The second line of input contains an integer height. The third line of input contains an integer n. The next n lines of input contain an integer.