Expression target sum
Given a string num containing only digits and an integer target, return all expressions formed by inserting the binary operators '+', '-', or '*' between the digits of num (in order, no reordering) so that the expression evaluates to target. No operand may have a leading zero (except the single digit 0). Return the expressions sorted lexicographically. The length of num is at most 10.
Implement
add_operators(num: str, target: int) → list[str]Examples
in
["123",6]out["1*2*3","1+2+3"]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 35 min
solution.py
InputExpectedGot
["123",6]["1*2*3","1+2+3"]not run yetsample