You are viewing a single comment's thread. Return to all comments →
def equalStacks(h1, h2, h3): s1, s2, s3 = sum(h1), sum(h2), sum(h3) h1.reverse() h2.reverse() h3.reverse() while True: minimum = min(s1, s2, s3) if not minimum: return minimum s1 -= h1.pop() if s1 > minimum else 0 s2 -= h2.pop() if s2 > minimum else 0 s3 -= h3.pop() if s3 > minimum else 0 if s1 == s2 == s3: return s1
Seems like cookies are disabled on this browser, please enable them to open this website
Equal Stacks
You are viewing a single comment's thread. Return to all comments →