FastPrepLongest Low-Slippage Execution Window
Problems/Longest Low-Slippage Execution Window

Longest Low-Slippage Execution Window

FalconX logoFalconX● MediumFULLTIMEOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report establishes the task identity and central capability. This practice contract supplies only the portable interface, deterministic boundary rules, and output serialization needed for consistent execution.

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 = 3maxSlippage = 8return = 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 = 0maxSlippage = 0return = 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.
See FalconX hiring insights
Saved
class Solution {
    public int longestExecutionWindow(String[][] logs, String targetVenue, int maxPriceRange, long maxSlippage) {
      // write your code here
    }
}
Checking account…