Code RoomSpreadsheet formula evaluator
HardPrep Room Coding #1239

Spreadsheet formula evaluator

CodingAlgorithms & data structuresSenior–Staff~45 min

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.

0:00 of about 45 min
InputExpectedGot
[{"A1":"5","A2":"A1+3","A3":"A1+A2"}]{"A1":5,"A2":8,"A3":13}not run yetsample