Reported September 2026
Hudson River Tradingstring

Minimize Expression Value with Parentheses

Reported by candidates from Hudson River Trading's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Hudson River Trading OA. Under 2s to a working solution.
Founder's read

Hudson River Trading reported this one in September 2026, and the input size is the first thing to read. The expression is two short numbers around a plus sign, so brute force isn't just allowed, it's the intended answer. If you have the OA in a day or two, this is a string-splitting enumeration problem with no deep trick. The danger is sloppy bookkeeping on the edges, not the idea. If you blank on the indexing live, StealthCoder runs invisibly as a safety net, but you should be able to write this yourself.

The problem

You are given a string expr representing the sum of two positive integers. Neither integer contains a zero in its decimal representation.
Insert exactly one pair of parentheses so that the plus sign is inside the parentheses and there is at least one digit between the plus sign and each parenthesis.
Any digits outside the parentheses form multiplication factors. If there are no digits on one side of the parentheses, the missing factor is 1.
For example, 741+12 may become 74(1+1)2, which is evaluated as 74 * (1 + 1) * 2 = 296. Placements such as (74)1+12 and 741(+12) are invalid.
Return the smallest value obtainable from any valid placement of the parentheses.
A solution with time complexity no worse than O(expr.length^4) will fit within the execution time limit.

Function
solution(expr: String) → int

Examples
Example 1
expr = "112+422"
return = 108
The placement 1(12+42)2 evaluates to 1 * 54 * 2 = 108, the smallest value among all valid placements.
Example 2
expr = "12+34"
return = 20
The placement 1(2+3)4 evaluates to 1 * 5 * 4 = 20, which is minimal.
Example 3
expr = "999+999"
return = 1998
Putting both complete numbers inside the parentheses yields (999+999) = 1998. Every placement with an outside factor is larger.

Constraints
expr contains exactly one plus sign.
At least one digit appears on each side of the plus sign.
Every digit in expr is between 1 and 9.
Every value produced by a valid placement fits in a signed 32-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Split expr at the plus sign into left and right strings. Pick a cut i in the left string for where the open parenthesis goes, and a cut j in the right string for where the close parenthesis goes. The open paren can sit before any left digit, including the very start. The close paren can sit after any right digit, including the very end. Digits left of the open paren form the prefix factor, and an empty prefix counts as 1. Digits right of the close paren form the suffix factor, also 1 if empty. The inside is the left tail plus the right head. Compute prefix * (leftTail + rightHead) * suffix and keep the minimum. That's O(n^2) pairs with cheap parsing, well under the stated O(n^4) bound. The common pitfall is treating an empty string as 0 instead of 1, which zeroes out the product. Also don't let a paren sit right against the plus sign. Each side of the plus must keep at least one digit inside.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Minimize Expression Value with Parentheses cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as minimize result by adding parentheses to expression. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Hudson River Trading's OA.

Hudson River Trading reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimize Expression Value with Parentheses FAQ

What's the trick to Minimize Expression Value with Parentheses?+

There isn't a clever one. Enumerate every legal pair of paren positions, evaluate each, and take the minimum. The constraint allows O(n^4), so even parsing substrings inside the double loop is fine. The work is getting the boundaries right, not finding an optimization.

How do I handle empty prefix or suffix factors?+

Default them to 1, not 0. If the open paren is at the very start of the string, the prefix factor is 1. If the close paren is at the very end, the suffix factor is 1. Using 0 turns the whole product into 0 and gives wrong answers.

Which placements are invalid?+

Any placement where a paren touches the plus sign without a digit between them is invalid. The examples show (74)1+12 and 741(+12) as illegal. So the left part inside the parens needs at least one digit, and so does the right part.

How hard is this really for a Hudson River Trading OA?+

The algorithm is easy. The risk is off-by-one errors in slicing and forgetting that digits are 1-9 only, so no zero parsing quirks. Test against the three given examples, especially 999+999 where both full numbers go inside the parens.

How do I prepare in 48 hours?+

Write this once from scratch with string slicing and int parsing. Then practice two-nested-loop enumeration over split points on similar string problems. Check the edge cases where the prefix or suffix is empty. That covers nearly everything this problem can throw at you.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Hudson River Trading.

OA at Hudson River Trading?
Invisible during screen share
Get it