Design a radar data pipeline that filters packets by an adjustable noise threshold

Quick Overview

Implement a radar data pipeline class that buffers raw packets, exports the ones whose signal strength is above a noise threshold, and keeps the rest. The threshold can change at runtime, so the question tests stateful class design, re-checking buffered data, strict comparisons and a deterministic sort order.

Design a radar data pipeline that filters packets by an adjustable noise threshold

Company: Anduril

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Other

Design the internal logic for a radar data pipeline component that ingests raw radar packets, filters out noise below a configured signal strength threshold, and exports the remaining detections to a downstream consumer. Each packet has an integer `id`, an integer `timestamp`, and an integer `signal_strength`. A packet qualifies as a detection only if its `signal_strength` is **strictly greater than** the current noise threshold. Detections are returned in non-decreasing order of `timestamp`, with ties broken by ascending `id`. Exported detections are removed from the internal buffer. The threshold may be updated at runtime via `set_threshold`. Updating the threshold re-evaluates every buffered packet, so previously suppressed packets may become detections (and vice versa). The constructor `RadarDataPipeline(threshold: int)` sets the initial noise threshold. Implement the following methods: - `ingest(packet_id: int, timestamp: int, signal_strength: int)`: adds a raw radar packet to the internal buffer. - `set_threshold(threshold: int)`: updates the noise threshold. Buffered packets are re-evaluated against the new threshold on the next export. - `export_detections() -> List[List[int]]`: removes and returns all currently qualifying detections as a list of `[packet_id, timestamp, signal_strength]`, sorted by timestamp ascending, then packet_id ascending. Packets at or below the threshold remain buffered. - `pending_count() -> int`: returns the number of packets currently held in the internal buffer. Example 1: ```text Input: ["RadarDataPipeline", "ingest", "ingest", "ingest", "export_detections", "pending_count"] [[50], [1, 10, 80], [2, 5, 30], [3, 15, 100], [], []] Output: [null, null, null, null, [[1, 10, 80], [3, 15, 100]], 1] Explanation: pipe = RadarDataPipeline(50) # threshold = 50 pipe.ingest(1, 10, 80) # buffer: [(1,10,80)] pipe.ingest(2, 5, 30) # buffer: [(1,10,80),(2,5,30)] 30 <= 50, noise pipe.ingest(3, 15, 100) # buffer: [(1,10,80),(2,5,30),(3,15,100)] pipe.export_detections() # [[1,10,80],[3,15,100]] sorted by timestamp pipe.pending_count() # 1 (packet 2 remains, it was below the threshold) ``` Example 2: ```text Input: ["RadarDataPipeline", "ingest", "ingest", "export_detections", "set_threshold", "export_detections", "pending_count"] [[100], [1, 5, 60], [2, 8, 150], [], [50], [], []] Output: [null, null, null, [[2, 8, 150]], null, [[1, 5, 60]], 0] Explanation: pipe = RadarDataPipeline(100) # threshold = 100 pipe.ingest(1, 5, 60) # buffer: [(1,5,60)] 60 <= 100, noise pipe.ingest(2, 8, 150) # buffer: [(1,5,60),(2,8,150)] pipe.export_detections() # [[2,8,150]] only packet 2 exceeds 100 pipe.set_threshold(50) # threshold lowered to 50 pipe.export_detections() # [[1,5,60]] packet 1 now qualifies (60 > 50) pipe.pending_count() # 0 (buffer drained) ``` ```hint When does status matter Ask at which moment a packet's status as a detection actually has to be known, and what that implies about the work `set_threshold` has to do. ``` ```hint Trace Example 2 A packet that is noise on the first export must still be available on the second one. Also check which side of the comparison a packet sitting exactly at the threshold falls on. ``` ### Constraints & Assumptions - `1 <= threshold <= 10^6` - `1 <= signal_strength <= 10^6` - `0 <= timestamp <= 10^9` - `1 <= packet_id <= 10^6` - At most `10^4` total operations across all methods. ### Clarifying Questions to Ask - Can two packets share the same `packet_id`, and if so, should a repeated id replace the earlier packet or sit beside it? - Do packets arrive in timestamp order, or can a later ingest carry an earlier timestamp? - How often is `export_detections` called compared with `ingest`, and how many noise packets can pile up between exports? - Should noise packets stay buffered indefinitely, or is there an age or size limit after which they are dropped? ### What a Strong Answer Covers - The internal state (buffer layout and threshold) and how it lets a threshold change apply to packets that are already buffered. - The detection rule and the output order, including the strict comparison and the tie on `timestamp`. - How an export removes detections while keeping noise packets, so `pending_count` stays correct. - The time and space cost of each method under the stated limits, and when a different data structure would be worth it. - Edge cases such as an empty buffer, a packet exactly at the threshold, and equal timestamps. ### Follow-up Questions - If exports run after almost every ingest and most packets are noise, how would you avoid rescanning the same noise packets on each export? - Noise packets can stay in the buffer forever. How would you bound memory, and what does dropping old packets mean for a later threshold change? - How would you make the class safe when one thread ingests and another exports? - How would the API change if the consumer wanted detections in batches of at most `k` at a time?

Overview: Implement a radar data pipeline class that buffers raw packets, exports the ones whose signal strength is above a noise threshold, and keeps the rest. The threshold can change at runtime, so the question tests stateful class design, re-checking buffered data, strict comparisons and a deterministic sort order.

Anduril logo
Anduril
Nov 24, 2026
mediumSoftware EngineerOtherSoftware Engineering Fundamentals
0
0

Design the internal logic for a radar data pipeline component that ingests raw radar packets, filters out noise below a configured signal strength threshold, and exports the remaining detections to a downstream consumer.

Each packet has an integer id, an integer timestamp, and an integer signal_strength. A packet qualifies as a detection only if its signal_strength is strictly greater than the current noise threshold. Detections are returned in non-decreasing order of timestamp, with ties broken by ascending id. Exported detections are removed from the internal buffer.

The threshold may be updated at runtime via set_threshold. Updating the threshold re-evaluates every buffered packet, so previously suppressed packets may become detections (and vice versa).

The constructor RadarDataPipeline(threshold: int) sets the initial noise threshold. Implement the following methods:

  • ingest(packet_id: int, timestamp: int, signal_strength: int) : adds a raw radar packet to the internal buffer.
  • set_threshold(threshold: int) : updates the noise threshold. Buffered packets are re-evaluated against the new threshold on the next export.
  • export_detections() -> List[List[int]] : removes and returns all currently qualifying detections as a list of [packet_id, timestamp, signal_strength] , sorted by timestamp ascending, then packet_id ascending. Packets at or below the threshold remain buffered.
  • pending_count() -> int : returns the number of packets currently held in the internal buffer.

Example 1:

Input:
["RadarDataPipeline", "ingest",    "ingest",   "ingest",     "export_detections", "pending_count"]
[[50],                [1, 10, 80], [2, 5, 30], [3, 15, 100], [],                  []]

Output: [null, null, null, null, [[1, 10, 80], [3, 15, 100]], 1]

Explanation:
pipe = RadarDataPipeline(50)      # threshold = 50
pipe.ingest(1, 10, 80)            # buffer: [(1,10,80)]
pipe.ingest(2, 5, 30)             # buffer: [(1,10,80),(2,5,30)]   30 <= 50, noise
pipe.ingest(3, 15, 100)           # buffer: [(1,10,80),(2,5,30),(3,15,100)]
pipe.export_detections()          # [[1,10,80],[3,15,100]]   sorted by timestamp
pipe.pending_count()              # 1   (packet 2 remains, it was below the threshold)

Example 2:

Input:
["RadarDataPipeline", "ingest",   "ingest",    "export_detections", "set_threshold", "export_detections", "pending_count"]
[[100],               [1, 5, 60], [2, 8, 150], [],                  [50],            [],                  []]

Output: [null, null, null, [[2, 8, 150]], null, [[1, 5, 60]], 0]

Explanation:
pipe = RadarDataPipeline(100)     # threshold = 100
pipe.ingest(1, 5, 60)             # buffer: [(1,5,60)]   60 <= 100, noise
pipe.ingest(2, 8, 150)            # buffer: [(1,5,60),(2,8,150)]
pipe.export_detections()          # [[2,8,150]]   only packet 2 exceeds 100
pipe.set_threshold(50)            # threshold lowered to 50
pipe.export_detections()          # [[1,5,60]]    packet 1 now qualifies (60 > 50)
pipe.pending_count()              # 0   (buffer drained)

Constraints & Assumptions

  • 1 <= threshold <= 10^6
  • 1 <= signal_strength <= 10^6
  • 0 <= timestamp <= 10^9
  • 1 <= packet_id <= 10^6
  • At most 10^4 total operations across all methods.

Clarifying Questions to Ask Guidance

  • Can two packets share the same packet_id , and if so, should a repeated id replace the earlier packet or sit beside it?
  • Do packets arrive in timestamp order, or can a later ingest carry an earlier timestamp?
  • How often is export_detections called compared with ingest , and how many noise packets can pile up between exports?
  • Should noise packets stay buffered indefinitely, or is there an age or size limit after which they are dropped?

What a Strong Answer Covers Guidance

  • The internal state (buffer layout and threshold) and how it lets a threshold change apply to packets that are already buffered.
  • The detection rule and the output order, including the strict comparison and the tie on timestamp .
  • How an export removes detections while keeping noise packets, so pending_count stays correct.
  • The time and space cost of each method under the stated limits, and when a different data structure would be worth it.
  • Edge cases such as an empty buffer, a packet exactly at the threshold, and equal timestamps.

Follow-up Questions Guidance

  • If exports run after almost every ingest and most packets are noise, how would you avoid rescanning the same noise packets on each export?
  • Noise packets can stay in the buffer forever. How would you bound memory, and what does dropping old packets mean for a later threshold change?
  • How would you make the class safe when one thread ingests and another exports?
  • How would the API change if the consumer wanted detections in batches of at most k at a time?