You are viewing a single comment's thread. Return to all comments →
It's readable
def equalStacks(h1, h2, h3): h1.reverse() h2.reverse() h3.reverse() stacks = [h1, h2, h3] heights = [sum(stack) for stack in stacks] while True: if len(set(heights)) == 1: return heights[0] else: idx = heights.index(max(heights)) heights[idx] -= stacks[idx].pop()
def equalStacks(h1, h2, h3): h1.reverse() h2.reverse() h3.reverse()
stacks = [h1, h2, h3] heights = [sum(stack) for stack in stacks] while True: if len(set(heights)) == 1: return heights[0] else: idx = heights.index(max(heights)) heights[idx] -= stacks[idx].pop()
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 →
It's readable