Search
⌘K

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.

Asked at:

Google

Google


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early October, 2024

Google

Google

Mid-level

Implement a calculator to reduce expressions like 'a + a * 4 - b + c + 3 * b' to '5a + 2b + c'

Early September, 2024

Google

Google

Mid-level

Given string "add(1,mul(2,pow(3,3)))", evaluate the final answer. Implement a basic calculator program.

Comments

Your account is free and you can post anonymously if you choose.

Leetcode 770. Basic Calculator IV | Hello Interview