← back to unit
Medium
# queues medium
Balance the Seesaw
Kids line up; the teacher seats them alternately — front of the line to the LEFT side, back of the line to the RIGHT side, repeat. ⚖️
You get the kids' weights (front first). Left takes the front, right takes the back, alternating (left first; if one kid remains, left gets them). Print left <total> right <total>.
Example:
Input: weights = [30, 20, 25, 35]
Output: left 50 right 60
Left takes the front 30, right takes the back 35, left takes the new front 20, right takes the new back 25 — left totals 30 + 20 = 50, right totals 35 + 25 = 60.
💡 need a hint?
q-balance-seesaw.py🔒 given lines are locked — write your code in between
loading...