FastPrepMaximum Observation in a Time Window
Problems/Maximum Observation in a Time Window

Maximum Observation in a Time Window

Akuna Capital logoAkuna Capital● MediumNEW GRADFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in Akuna Capital new grad and full-time onsite interviews. One quant researcher report asks for on_observation() and get_max(timestamp, window), with an open interval. Three other reports ask for the maximum logged in the last 60 seconds, but do not say whether the endpoints count. Here, both endpoints are left out for every width, including 60. We also chose these rules: call times are whole seconds, operations come in time order, we set limits, we defined the result for an empty window, and the operations come as one batch. Our version is about 90% the same as the reported questions.

Maintain observations with timestamps measured in whole seconds. An insertion stores one timestamp and integer value. A query get_max(T, window) asks for the largest stored value whose timestamp satisfies T - window < timestamp < T. Both endpoints are excluded.

Process the rows of operations in order:

  • [0, timestamp, value]: insert an observation, representing on_observation().
  • [1, T, window]: query the open time interval above. Use window = 60 for a previous-sixty-seconds query.

Return one integer per query, in query order. If a query has no matching observation, return -2147483648 for that query. Insertions produce no output. An empty stream or a stream with no queries returns an empty array.

The second cell of every row is the logical call time. These times are nondecreasing across all operations, and equal times are allowed. Only insertions already processed are visible. Multiple observations may share a timestamp, including different values.

Queries do not remove observations. A later query may use a larger window and include data that an earlier narrow query did not include. This is a window measured in elapsed seconds, not a limit on the number of observations. A zero-width window is empty.

Function

windowMaxima(operations: int[][]) → int[]

Examples

Example 1

operations = [[0,0,8],[0,1,5],[0,59,7],[0,60,100],[1,60,60],[1,61,60]]return = [7,100]

The first window is (0,60), so only values 5 and 7 qualify. The observations at times 0 and 60 are on excluded endpoints. The next window is (1,61), which excludes time 1 and includes the value 100 at time 60.

Example 2

operations = [[0,1,-5],[1,1,10],[1,2,1],[1,2,2],[1,2,0]]return = [-2147483648,-2147483648,-5,-2147483648]

The observation at time 1 is excluded by the first query’s right endpoint and the second query’s left endpoint. It is inside (0,2), giving -5 for the third query. The last query has width zero and is empty.

Example 3

operations = [[0,0,100],[0,5,3],[1,10,4],[1,11,20]]return = [-2147483648,100]

The narrow interval (6,10) contains neither observation. The later interval (-9,11) contains both, so its maximum is 100. Earlier queries must not discard old data that a wider window may need.

Constraints

  • 0 <= operations.length <= 100000.
  • Every operation has exactly 3 integers.
  • Every integer in operations is between -1000000 and 1000000000, inclusive.
  • The first integer is 0 for insertion or 1 for query.
  • Every timestamp is between 0 and 1000000000. Timestamps are nondecreasing across the entire operation stream.
  • For an insertion, the third integer is a value between -1000000 and 1000000.
  • For a query, the third integer is a window width between 0 and 1000000000.

More Akuna Capital Onsite Interview questions

  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Positive Nth Root with Gradient DescentPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Count Set Bits in an Integer ArrayONSITE INTERVIEW · Seen Jan 2026
  • Remove Duplicates While Preserving OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2025
  • First and Last Position in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2022
  • Stream Median, Mean and MaximumPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2021
  • Group AnagramsONSITE INTERVIEW · Seen Aug 2021
  • Maximum Stock Profit with a Transaction LimitONSITE INTERVIEW · Seen Aug 2021
  • Rotate a Square MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2020
  • Trace of a Square MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen May 2019

Similar questions at other companies

  • Employee Ratings Management SystemAmazon · PHONE SCREEN
  • Running Medians and PercentilesStackAdapt · PHONE SCREENStackAdapt interview questions
  • Range ModuleWalmart · PHONE SCREENWalmart interview questions
  • Dynamic K-th Largest QueriesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Order Sequence Prefix Counts and QuantitiesHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
  • Count Later Lower ReadingsRippling · ONSITE INTERVIEWRippling interview questions
  • Centered Block Placement QueriesRoblox · OARoblox interview questions
  • Maximum Profit from an Increasing Price TripletOdoo · OAOdoo interview questions
  • Maximum Laptop Rating in a Price RangePostman · OAPostman interview questions
  • Search a Row- and Column-Sorted MatrixByteDance · ONSITE INTERVIEWByteDance interview questions

Interview reports that mention this question

  • Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)

Akuna Capital interview experiences

  • Akuna Capital Quant Trader and QR Interviews: 5 Experiences
  • Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
  • Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
  • Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
  • Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public int[] windowMaxima(int[][] operations) {
        // write your code here
    }
}
Checking account…