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

Question

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.

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.