You are viewing a single comment's thread. Return to all comments →
def poisonousPlants(p): mday,s = 0, [] for i in p: if not(s) or i <= s[0][0]: s=[[i,0]] elif i > s[-1][0]: s.append([i,1]) else: d = 1 while s and i <= s[-1][0]: d = max(d, s.pop()[1]+1) s.append([i,d]) mday = max(mday,s[-1][1]) return mday
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 →