InterviewLegend

Sliding Windows

Alex Chen28 min readUpdated 328 real interview reports

Grouping & Intervals covers the window that grows on the right and shrinks on a repeat. IBM's assessment asks for a few other kinds. A window can hold a fixed number of characters, a span of seconds that widens and narrows with the traffic, or a running product that has to be trimmed whenever it goes over a target. The loop looks the same in all three, and only the rule for moving the left edge changes.

These are the log-processing problems that run through IBM's prompts, the grouping, deduplicating and counting over a window. With intervals included they're close to 29% of IBM's coding, and any of them could arrive as a log. One looks for a pattern that keeps coming back in a string, one watches a gateway for callers over a rate, and one asks how many stretches of compounding rates land exactly on a target.

The IBM angle
On IBM's grader, window bugs are usually at the left edge. Move it one place too late or too early and the samples still pass while a boundary test fails. When the window is measured in seconds, two requests exactly t seconds apart belong in different windows, so your eviction test has to cover that pair. When the window holds a product, you divide out the left value on every overshoot, and a run of ones lets several starts share one product. Write the eviction condition as a single line, then trace the pair that lands exactly on it.

IBMPremium lesson · Coding round

The 3 IBM problems are below.

  1. A Premium questionCoding · Medium
  2. A Premium questionCoding · Medium
  3. A Premium questionCoding · Medium

Each with hints, the follow-up and a tested solution.

Get the IBM questions

$49 a year · all 100 companies · cancel anytime

From 328 IBM reports, forum threads behind logins and write-ups in Chinese.

Had your IBM interview?Tell us what they asked. Reviewed before it goes in, never with your name.
IBM interview guide

Know what IBM asks before you walk in.

30 coding · 3 system design · 13 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.