You are viewing a single comment's thread. Return to all comments →
Here's my Ruby implementation:
def poisonousPlants(p) i=0 while p[i] p[i] = [p[i]] if p[i-1] and p[i-1][-1] >= p[i][0] p[i-1] += p[i]; p.delete_at i else i+=1 end end i, days = 1, 0 while p[i] p[i].shift if p[i].empty? p.delete_at i elsif p[i-1] and p[i-1][-1] >= p[i][0] p[i-1] += p[i] p.delete_at i else i += 1 end i = 1 and days += 1 unless p[i] end days end
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 →
Here's my Ruby implementation: