Expression Add Operators
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given a string num of digits and an integer target. Between any two adjacent digits you may insert +, -, *, or nothing (which joins the digits into a longer operand).
Return every resulting expression that evaluates to target using normal precedence (* before + and -). Operands must not have leading zeros: "05" is not allowed as an operand, but "0" by itself is. No unary minus may be added before the first digit.
Return the expressions in any order; each distinct expression string appears once.
Examples
Constraints
- 1 <= num.length <= 10
- `num` consists only of digits
- -2^31 <= target <= 2^31 - 1
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.