There are a number of plants in a garden. Each of the plants has been treated with some amount of pesticide. After each day, if any plant has more pesticide than the plant on its left, being weaker than the left one, it dies.
You are given the initial values of the pesticide in each of the plants. Determine the number of days after which no plant dies, i.e. the time after which there is no plant with more pesticide content than the plant to its left.
// pesticide levels
Use a -indexed array. On day , plants and die leaving . On day , plant in dies leaving . There is no plant with a higher concentration of pesticide than the one to its left, so plants stop dying after day .
Complete the function poisonousPlants in the editor below.
poisonousPlants has the following parameter(s):
int p[n]: the pesticide levels in each plant
- int: the number of days until plants no longer die from pesticide
The first line contains an integer , the size of the array .
The next line contains space-separated integers .