Code Room
CodingHardcod-g353
Subject BacktrackingLevel Senior–Staff~40 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.