Problem
Given a string of digits num and an integer target, insert the operators +, - or * between digits (or nothing, which joins digits into a longer number) so that the expression evaluates to target using normal precedence (* before + and -). Return all expressions that work, in any order. Numbers in the expression may not have leading zeros (05 is not allowed, 0 is).
Example 1
- Input
- num = "123", target = 6
- Output
- ["1+2+3", "1*2*3"]
Example 2
- Input
- num = "232", target = 8
- Output
- ["2*3+2", "2+3*2"]
Example 3
- Input
- num = "105", target = 5
- Output
- ["1*0+5", "10-5"]
Constraints
1 <= num.length <= 10num consists of only digits.-2^31 <= target <= 2^31 - 1