Example 1
Input
add_operators('123', 6)
Output
['1+2+3', '1*2*3']
'1+2+3' and '1*2*3' both evaluate to 6.
Full lesson preview
Insert operators (+, -, *) between digits of a number string to generate expressions that evaluate to a target value.
Problem statement
Task
Examples
Input
add_operators('123', 6)
Output
['1+2+3', '1*2*3']
'1+2+3' and '1*2*3' both evaluate to 6.
Input format
Output format
Constraints
Samples
Input
add_operators('105', 5)
Output
['1*0+5', '10-5']
Two expressions evaluate to 5: '1*0+5' and '10-5'.