FastPrepTriggered Order Event Filter
Problems/Triggered Order Event Filter

Triggered Order Event Filter

Headlands Technologies logoHeadlands Technologies● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Headlands Technologies onsite interview. The report asks for an object interface built around an Order. After five orders with price at least 100, it gives the next three BUY orders. Here those numbers are settings, there is one activation, and you return the original indices. We chose the input shape, the reset rule and the limits. A later post with the same wording was treated as a repost, not as a separate report. Our version is about 85% the same as the reported question.

You receive orders in arrival order. Each row is [price, side], where side == 1 means BUY and side == 0 means SELL. An order is identified by its zero-based position in the input; identical rows remain distinct orders.

Start an inactive filter. Count every order whose price >= threshold, regardless of side. The first order that brings this count to triggerCount activates the filter. That triggering order is excluded from the output.

After activation, return the indices of the next takeCount BUY orders, preserving arrival order. Their prices do not need to meet the threshold, and SELL orders do not use up the requested count. Activation occurs only once; later qualifying orders do not reset or restart the filter.

If activation never occurs, return an empty array. If fewer BUY orders remain, return all that remain. A zero take count also returns an empty array. Implement filterOrdersAfterTrigger; its finite array interface can be backed by an object that consumes one order at a time.

Function

filterOrdersAfterTrigger(orders: int[][], triggerCount: int, threshold: int, takeCount: int) → int[]

Examples

Example 1

orders = [[100,0],[80,1],[110,1],[100,0],[90,0],[130,0],[100,1],[5,0],[2,1],[999,0],[3,1],[200,1]]triggerCount = 5threshold = 100takeCount = 3return = [8,10,11]

The fifth qualifying order is index 6, which is excluded even though it is BUY. The next three BUY orders have indices 8,10,11.

Example 2

orders = [[11,1],[9,1],[10,0],[1,0],[2,1],[8,1]]triggerCount = 2threshold = 10takeCount = 3return = [4,5]

Both sides count toward activation. Index 2 activates the filter; only two subsequent BUY orders exist, at 4 and 5.

Example 3

orders = [[10,1],[0,1],[20,1]]triggerCount = 1threshold = 10takeCount = 0return = []

A zero take count requests no orders, so the result is empty.

Constraints

  • 0 <= orders.length <= 100000.
  • Each row contains exactly two integers with 0 <= price <= 1000000000 and side equal to 0 or 1.
  • 1 <= triggerCount <= 1000000000.
  • 0 <= threshold, takeCount <= 1000000000.
  • All orders are valid and processed in the supplied order. There are no cancellations, amendments, resets or concurrent arrivals.

More Headlands Technologies interview questions

  • As-Of JoinOA · ONSITE INTERVIEW · Seen Aug 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2024
  • Best Time to Buy and Sell Stock IIONSITE INTERVIEW · Seen Apr 2024
  • House RobberONSITE INTERVIEW · Seen Apr 2024
  • Merge IntervalsONSITE INTERVIEW · Seen Apr 2024
  • Net Position Calculation from API SnapshotsONSITE INTERVIEW · Seen Apr 2024
  • Disaster RecoveryOA · Seen Nov 2026
  • Integer Compression OffsetPHONE SCREEN · Seen Oct 2026
  • Array Interval SumsOA · Seen Oct 2026
  • Job Runner Chain ReportsOA · Seen Oct 2026

Similar questions at other companies

  • Ring Buffer OperationsAmazon · ONSITE INTERVIEW
  • Basic In-Memory SpreadsheetGoogle · ONSITE INTERVIEWGoogle interview questions
  • Predict Runtime Method DispatchAMD · ONSITE INTERVIEWAMD interview questions
  • Apply Overridden Integer TransformsOptimus Information · ONSITE INTERVIEWOptimus Information interview questions
  • Mutable Record Store with Error ResultsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • Recent Hit CounterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Phone Spam Report CounterPinterest · ONSITE INTERVIEWPinterest interview questions
  • Task Row ModificationsNotion · ONSITE INTERVIEWNotion interview questions
  • Card Transaction StreamCapital One · ONSITE INTERVIEWCapital One interview questions
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
All Headlands Technologies interview questionsSee Headlands Technologies hiring insights
Saved
class Solution {
    public int[] filterOrdersAfterTrigger(int[][] orders, int triggerCount, int threshold, int takeCount) {
        // write your code here
    }
}
Checking account…