Expression Add Operators
Hard · Backtracking · about 35 minutes
Asked at Meta, Google, Pinterest, Amazon, Bloomberg.
Given a string num of digits and an integer target, return every way to insert the binary operators '+', '-' and '*' between the digits so that the expression evaluates to target, in any order. Operands may not have leading zeros ("05" is invalid, "0" is fine), and you may also leave digits joined.