Future Stock Price

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 hit you with "Future Stock Price" in September 2024, and you've got 24-72 hours to figure out the angle. The problem title screams prediction or time-series logic, but the real test is whether you spot the dynamic-programming structure hiding underneath. You're not building a stock predictor. You're solving a constraint-satisfaction problem disguised as finance. StealthCoder sits ready as your safety net if the pattern doesn't click in the first 10 minutes of the live OA.

Pattern and pitfall

Future Stock Price almost always reduces to one of two shapes: either you're computing the maximum or minimum value reachable at a given time step subject to transition rules, or you're counting the number of distinct price sequences that satisfy some constraint. Both map cleanly to dynamic programming where state is (current_time, current_price) or (current_time, price_range), and transitions follow the allowed price movements per step. The trap is over-engineering: candidates often try greedy (won't work if price can go negative or the goal is to minimize intermediate swings) or simulation (too slow for large time horizons). DP lets you prune entire branches of the search space. If the problem specifies starting price, ending price, and per-step deltas, you're building a table where dp[t][p] = count of ways to reach price p at time t. Watch for off-by-one errors in time indexing and boundary conditions at time zero.

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 Future Stock Price 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

⏵ 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.

Future Stock Price FAQ

Is this really a DP problem or can I simulate it?+

If the time horizon is under 100 steps and price range is small (under 1000), simulation works. Beyond that, you'll timeout. DP is the pattern. Build a table keyed on (time, price) and iterate forward, accumulating valid transitions at each step.

What's the most common mistake on this problem?+

Forgetting to initialize the base case correctly at time zero. If starting price is fixed, dp[0][starting_price] = 1 and all others are zero. Forgetting this causes cascading errors in all downstream cells.

Do I need to track the actual sequence of prices or just the count/value?+

Usually just the final answer. If the problem asks for the actual path, you'll need a parent pointer or reconstruction step. Read the output spec carefully. Most variants want the max price, min price, or count of valid sequences.

How do I handle negative prices or price constraints?+

Map prices to indices if they're negative or sparse. If prices range from -100 to 100, use an offset so index zero is -100. Or use a hash table (dict/map) keyed on actual price instead of an array, which auto-handles sparse ranges.

What if the problem says prices can only increase by 1 or decrease by 1 each step?+

That's a strong hint it's DP. You're building a triangular or trapezoidal table where at time t, reachable prices form a contiguous range. Use that structure to optimize space from O(time * range) to O(range) with rolling arrays.

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