04. Expression Add Operators
β GFG solution to the Expression Add Operators problem: insert +, -, * between digits to reach a target value using DFS & backtracking. π
π§© Problem Description
π Examples
Example 1
Input: s = "124", target = 9
Output: ["1+2*4"]
Explanation: The valid expression that evaluates to 9 is 1 + 2 * 4Example 2
Input: s = "125", target = 7
Output: ["1*2+5", "12-5"]
Explanation: The two valid expressions that evaluate to 7 are 1 * 2 + 5 and 12 - 5.Example 3
Example 4
π Constraints
β
My Approach
Backtracking with DFS
π Time and Auxiliary Space Complexity
βοΈ Code (C)
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated