IIBM·DSABand 8Technical Phone Screen
Expression Add Operators
Problem
Insert +, -, * between digits of a string so the expression evaluates to a target; return all valid expressions.
Example
num="123", target=6 -> ["1+2+3","1*2*3"]
Constraints
- 1 ≤ |num| ≤ 10
Approach
Backtracking carrying the running value and the last multiplied operand.
added 6 days ago