Code Room
CodingHardcod-g673
Subject Expression evaluationLevel Senior–Staff~45 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Evaluate a tiny spreadsheet. You are given a dict mapping cell names (e.g. 'A1') to formula strings. A formula is either a number (e.g. '5'), a cell reference (e.g. 'A2'), or a sum of operands joined by '+', where each operand is a number or a cell reference (e.g. 'A1+B2+3'). Resolve every cell to its integer value, following references. Return a dict mapping each cell name to its value. There are no cycles, and every referenced cell exists.

Implement
eval_spreadsheet(cells: dict[str,str]) → dict[str,int]
Examples
in[{"A1":"5","A2":"A1+3","A3":"A1+A2"}]out{"A1":5,"A2":8,"A3":13}
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.