Back to problems

Build an Arithmetic Expression to Reach a Target

Algorithm · Waymo · Hard

Requirements Implement the following function for three supplied numbers and a target value: Place +, -, or * between the numbers and use parentheses wherever needed, allowing any valid ordering of the supplied values. Return an expression whose result equals target if at least one such expression can be formed. If no valid expression exists, report that no solution was found. Follow-up: adapt the method to support an arbitrary number n of supplied values. Examples Example 1…

Checking your access…