You are viewing a single comment's thread. Return to all comments →
Great solution mister.
My Python3 version:
def poisonousPlants(plants): stack = [] maxDays = -math.inf for plant in plants: days = 1 while stack and stack[-1][0] >= plant: _, d = stack.pop() days = max(days, d + 1) if not stack: days = 0 maxDays = max(maxDays, days) stack.append((plant, days)) return maxDays
Seems like cookies are disabled on this browser, please enable them to open this website
Poisonous Plants
You are viewing a single comment's thread. Return to all comments →
Great solution mister.
My Python3 version: