Reported September 2026
Decagonsliding window

Rolling CSAT Tracker

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

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

Decagon reported this one in September 2026, and the detail that trips people is the output format. Each QUERY returns a reduced fraction like "8/3", or EMPTY when nothing is in the window. It's a rolling window over a stream of ADD and QUERY operations with nondecreasing timestamps. That's a queue plus running totals, nothing exotic. The work is in the edge cases: empty windows, reduction by gcd, and window boundaries. If you blank mid-assessment, StealthCoder runs invisibly on your desktop and gives you a working solution to sanity-check against. Know the shape first and you won't need it.

The problem

Process timestamped customer-satisfaction operations in nondecreasing time order. ADD t score records a score from 1 through 5. QUERY t asks for the average of scores whose timestamps lie in [t-windowSize+1, t].
Return one reduced sum/count fraction per query, or EMPTY when the active window has no scores.

Function
rollingCsat(operations: String[], windowSize: int) → String[]

Examples
Example 1
operations = ["ADD 1 5","ADD 3 3","QUERY 3","QUERY 6"]
windowSize = 5
return = ["4/1","3/1"]
At time 3 both scores are active; at time 6 only the score from time 3 remains.
Example 2
operations = ["QUERY 2","ADD 2 4","QUERY 2"]
windowSize = 3
return = ["EMPTY","4/1"]
The tracker distinguishes an empty window from a numeric average.
Example 3
operations = ["ADD 0 1","ADD 1 2","ADD 2 5","QUERY 2"]
windowSize = 3
return = ["8/3"]
The exact rational average is returned without floating-point rounding.

Constraints
1 <= operations.length <= 2 * 10^5.
1 <= windowSize <= 10^9.
Timestamps are nonnegative and nondecreasing; scores are integers from 1 through 5.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that timestamps never go backward, so you don't need a heap or a binary search. Keep a queue of (timestamp, score) pairs plus a running sum and count. On QUERY t, pop from the front while the timestamp is less than t - windowSize + 1, subtracting from the sum and count. Then if count is 0, output EMPTY. Otherwise divide sum and count by gcd(sum, count) and print sum/count. Note Example 1 expects "4/1" for a 4 average, so don't drop the denominator when it's 1. Pitfalls: using floating point, forgetting to evict on QUERY, and an off-by-one on the window start. Each element enters and leaves once, so it's O(n) overall. Timestamps and windowSize fit in int, but t - windowSize + 1 can go negative, so that's fine to compare. If the boundary logic slips under pressure, StealthCoder is the hedge during the live OA.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Rolling CSAT Tracker 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Decagon reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Rolling CSAT Tracker FAQ

What's the trick in Rolling CSAT Tracker?+

Use a queue with a running sum and count. Timestamps are nondecreasing, so expired entries are always at the front. Evict them on each QUERY, then reduce sum/count by gcd. No heap or sorting needed. Each entry is added and removed once, so total work is linear.

How do I get the window boundary right?+

The window is [t-windowSize+1, t], inclusive on both ends. Evict any entry with timestamp strictly less than t-windowSize+1. Test with Example 1: at t=6 and windowSize=5, the start is 2, so the score at time 1 is gone and the one at time 3 stays.

Why return a fraction instead of a decimal?+

The problem asks for the exact rational average, so floating point is off the table. Compute g = gcd(sum, count) and print sum/g + "/" + count/g. A whole-number average still prints with a denominator, like 4/1. Only an empty window prints EMPTY.

What edge cases should I test before submitting?+

Test a QUERY before any ADD, which must return EMPTY. Test a window where every score has expired. Test multiple ADDs at the same timestamp, and a query exactly at the window edge. Also check a large windowSize like 10^9 so your start value doesn't break.

How should I prepare in 48 hours for a Decagon OA like this?+

Practice sliding window and queue problems that process a stream with running aggregates. Write the evict-then-answer loop from memory, plus a gcd helper. Reported in September 2026, this style rewards clean state handling over clever algorithms, so rehearse edge cases rather than new topics.

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

OA at Decagon?
Invisible during screen share
Get it