Days Until No Plant Dies

Asked at Walmart Labs · Coding Questions · Difficulty: Hard · Last asked Feb 24, 2026

A row of plants is given as a list of pesticide amounts, left to right. Every day, each plant that has strictly more pesticide than the plant immediately to its left dies. All such plants die at the same moment, and then the survivors close ranks, so a survivor can get a new left neighbour. Count the days on which at least one plant dies before the row stops changing.

Loading the problem…