There are a number of plants in a garden. Each of these 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. Print the number of days after which no plant dies, i.e. the time after which there are no plants with more pesticide content than the plant to their left.
For example, pesticide levels . Using a -indexed array, day plants and die leaving . On day , plant of the current array dies leaving . As there is no plant with a higher concentration of pesticide than the one to its left, plants stop dying after day .
Complete the function poisonousPlants in the editor below. It must return an integer representing the number of days until plants no longer die from pesticide.
poisonousPlants has the following parameter(s):
p: an array of integers representing pesticide levels in each plant
The first line contains an integer , the size of the array .
The next line contains space-separated integers .
Output an integer equal to the number of days after which no plants die.