Reported September 2026
Attentivebinary search

Messages in an Inclusive Timestamp Range

Reported by candidates from Attentive's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Attentive OA. Under 2s to a working solution.
Founder's read

Two parallel arrays, a sorted timestamp list, and an inclusive [start, end] window. That's the Attentive OA question reported in September 2026, and it looks easier than it is. The pattern is binary search on sorted data, and the traps hide in the duplicates and the edges. If you've got an invite for the next day or two, this is a ten-minute problem when you see it clearly. If you blank on the boundary logic mid-assessment, StealthCoder runs invisibly on your desktop as a safety net and hands you the solution while you keep your cool.

The problem

In-memory logs are stored in nondecreasing timestamp order. Parallel arrays timestamps and messages describe each log entry.
Given inclusive bounds start and end, return the messages for every entry whose timestamp is in [start, end]. Preserve input order and retain entries with duplicate timestamps.

Function
messagesInRange(timestamps: long[], messages: String[], start: long, end: long) → String[]

Examples
Example 1
timestamps = [1,2,2,5,8]
messages = ["a","b","c","d","e"]
start = 2
end = 5
return = ["b","c","d"]
Both entries at timestamp 2 and the entry at timestamp 5 lie inside the inclusive range.
Example 2
timestamps = [3,7,9]
messages = ["x","y","z"]
start = 10
end = 12
return = []
No timestamp lies in the requested range.

Constraints
0 <= timestamps.length == messages.length <= 200000.
timestamps is sorted in nondecreasing order.
-10^18 <= timestamps[i], start, end <= 10^18.
start <= end.
Each message has length at most 200.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that timestamps are already sorted, so you don't need to scan everything. Find the first index where timestamps[i] >= start (lower bound). Find the first index where timestamps[i] > end (upper bound). Slice messages from lower to upper, exclusive on the right. Duplicates take care of themselves because the lower bound lands on the first copy and the upper bound lands past the last copy. The common pitfall is using a lower bound for end, which drops entries equal to end. Another is an off-by-one on the slice. A plain linear scan is O(n) and passes at 200000 entries, so it's a fine fallback. Values reach 10^18, so use 64-bit types and avoid computing mid as (lo+hi) in a type that can overflow. Empty arrays must return an empty result. If the binary search logic slips live, StealthCoder is your hedge to get the boundaries right.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Messages in an Inclusive Timestamp Range 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Attentive's OA.

Attentive reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Messages in an Inclusive Timestamp Range FAQ

How hard is the Attentive messages-in-range problem really?+

Easy to medium. The logic is short, but boundary mistakes cause most failures. If you know lower bound and upper bound on a sorted array, it's a few lines. A linear filter also works at 200000 entries, so you have a safe fallback.

What's the trick to handle duplicate timestamps?+

Use a lower bound for start (first index with timestamp >= start) and an upper bound for end (first index with timestamp > end). Everything between them is included, duplicates and all, in original order. No special duplicate handling needed.

Do I need binary search or is a linear scan enough?+

With n up to 200000, a single linear pass is fast enough. Binary search is the cleaner answer since the input is sorted, and it shows you read the constraints. Write the linear version first if you're nervous, then optimize.

What edge cases should I test before submitting?+

Empty arrays, a range entirely before or after all timestamps, start equal to end, and duplicates at both boundaries. Also test values near 10^18 and negatives, so use a 64-bit type. Example 2 from the statement covers the empty-result case.

How do I prepare for this in 48 hours?+

Write lower bound and upper bound from scratch until you can do it without thinking. Then solve this one end to end with both examples. Practice returning a sub-slice by index range. That's enough, the problem has no deeper twist.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Attentive.

OA at Attentive?
Invisible during screen share
Get it