Code RoomExpression add operators
HardPrep Room Coding #922

Expression add operators

CodingAlgorithms & data structuresSenior–Staff~40 min

Given a string num of digits (length 1..10) and an integer target, insert the binary operators '+', '-', or '*' between digits (or none, joining digits into a multi-digit number) so the resulting expression evaluates to target. Operands may not have leading zeros (so '05' is illegal, but a lone '0' is fine). Return all valid expressions sorted ascending; multiplication has standard precedence over addition and subtraction.

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 40 min
InputExpectedGot
["123",6]["1*2*3","1+2+3"]not run yetsample