You are viewing a single comment's thread. Return to all comments →
Python while loop
def equalStacks(h1: list[int], h2: list[int], h3: list[int]) -> int: h1_sum, h2_sum, h3_sum = sum(h1), sum(h2), sum(h3) h1_idx, h2_idx, h3_idx = 0, 0, 0 while not (h1_sum == h2_sum == h3_sum): if h1_sum > h2_sum and h1_sum > h3_sum: h1_sum -= h1[h1_idx] h1_idx += 1 elif h2_sum > h3_sum: h2_sum -= h2[h2_idx] h2_idx += 1 else: h3_sum -= h3[h3_idx] h3_idx += 1 return h1_sum
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 →
Python while loop