Leetcode 770. Basic Calculator IV
Parse and evaluate a space-separated arithmetic expression with integers, multi-letter variables, parentheses and +, -, * (obeying precedence), applying given variable substitutions, then expand and simplify into polynomial-like terms by multiplying out, combining like terms (summing coefficients), dropping zero coefficients, and returning terms sorted by descending degree and lexicographic order. Key challenges: implement a parser/evaluator with correct precedence and represent terms as (coefficient, sorted variable multiset) to support multiplication, hashing, and ordering.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early October, 2024
Implement a calculator to reduce expressions like 'a + a * 4 - b + c + 3 * b' to '5a + 2b + c'
Hello Interview Premium
Your account is free and you can post anonymously if you choose.