Code RoomExpression evaluator
HardPrep Room Coding #1020

Expression evaluator

CodingAlgorithms & data structuresSenior–Staff~40 min

Evaluate an expression given as a list of tokens, where each token is either an integer (as a Python int) or one of the operator strings '+','-','*','/','^'. '^' is exponentiation and is RIGHT-associative; '*','/' are left-associative with precedence above '+','-'; '^' has the highest precedence. Division is integer division truncating toward zero and operands are positive enough that exponents are small (0..6). Use the shunting-yard algorithm. The token list is a valid infix expression with no parentheses. Return the integer result.

Implement
eval_infix(tokens: list) → int
Examples
in[[2,"+",3,"*",4]]out14
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 40 min
InputExpectedGot
[[2,"+",3,"*",4]]14not run yetsample