Longest Low-Slippage Execution Window
Reported by candidates from FalconX's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this FalconX problem is treating it like a plain sliding window and forgetting the filter and sort come first. This one was reported in September 2026. You filter rows to targetVenue, stable-sort by timestamp, then find the longest contiguous window where price range and total slippage both stay under their caps. The hint says dynamic programming, but the real shape is a window over a cleaned array. If you blank on the live OA, StealthCoder is the invisible safety net that reads the problem and hands you a working solution.
The problem
Each execution log row is [timestamp, venue, fillPrice, benchmarkPrice, volume], with integer numeric fields encoded as strings. Filter to targetVenue, then sort by increasing timestamp; equal timestamps retain input order. The slippage cost of a row is abs(fillPrice - benchmarkPrice) * volume. Return the maximum length of a contiguous filtered window whose fill-price range is at most maxPriceRange and whose total slippage cost is at most maxSlippage. Return 0 if no target row is valid. Function longestExecutionWindow(logs: String[][], targetVenue: String, maxPriceRange: int, maxSlippage: long) → int Examples Example 1 logs = [["3","A","103","100","2"],["1","A","100","100","5"],["2","B","90","90","1"],["2","A","101","100","2"]] targetVenue = "A" maxPriceRange = 3 maxSlippage = 8 return = 3 After filtering and sorting, all three A rows have range 3 and total slippage 8. Example 2 logs = [["1","B","10","10","1"]] targetVenue = "A" maxPriceRange = 0 maxSlippage = 0 return = 0 No row belongs to the target venue. Constraints 0 <= logs.length <= 500. Prices, volume, and bounds are nonnegative integers. Slippage totals fit in a 64-bit signed integer.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Parse the strings to integers first. Filter to the target venue, then use a stable sort on timestamp so equal timestamps keep input order. Precompute each row's cost as abs(fill - benchmark) * volume, and use a long for sums. Now run two pointers. Expand right, add the cost to a running sum, and track the min and max fill price in the window with two monotonic deques. While range exceeds maxPriceRange or the sum exceeds maxSlippage, shrink left. Both conditions only get easier as the window shrinks, so the window is monotone and this works. The common pitfall is skipping the stable sort, or using int for slippage and overflowing. With n up to 500, even an O(n^2) scan with running min and max passes, so don't over-engineer it. If you freeze mid-OA, StealthCoder is the hedge that gives you the full approach live.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Longest Low-Slippage Execution Window 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 StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass FalconX's OA.
FalconX 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.
Longest Low-Slippage Execution Window FAQ
What's the trick in the FalconX Longest Low-Slippage Execution Window problem?+
Clean the data first, then slide a window. Filter to the target venue, stable-sort by timestamp, compute per-row slippage, and keep the longest window satisfying both the price range cap and the slippage cap. Both constraints are monotone, so shrinking the window always helps.
Is this really dynamic programming?+
Not in practice. The hint says DP, but the solution is a two-pointer window over the filtered, sorted rows. You don't need a DP table. The only state is a running slippage sum and the window's min and max fill price.
How do I track the price range inside the window?+
Use two monotonic deques, one for the max and one for the min fill price. With only 500 rows, you can also recompute min and max by scanning each candidate window. That's O(n^2) and still fast enough.
What edge cases break most first attempts?+
Forgetting the stable sort on equal timestamps, overflowing int on slippage totals, and not returning 0 when no row matches the venue. Also remember the numbers arrive as strings, so parse them before comparing or subtracting.
How do I prepare for this in 48 hours?+
Write a variable-size sliding window with a monotonic deque once, then write this exact problem from scratch. Test on the two examples, an empty logs array, and a case with tied timestamps. That covers nearly everything this problem can throw at you.