Reported April 2026
Maven Clinicsimulation

Paginate Provider Listings with Per-Page Diversity

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

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

Maven Clinic reported this one in April 2026, and the detail that trips people is the rating threshold: a listing at exactly highScoreThreshold counts as high-rated, so a provider can show up twice on one page. The task is paginating provider listings with per-page diversity. It's a simulation problem dressed up as search ranking. You scan, select, defer, pad, repeat. If your OA invite lands in the next day or two, read the rules twice, because the logic is simple and the edge cases are where points disappear. StealthCoder is the safety net if you blank mid-assessment.

The problem

Search results are supplied in descending relevance order. Each element of results is an original five-field CSV string provider_id,listing_id,rating,consultation_fee,city. The provider ID is the first field and the numeric rating is the third field.
Partition the results into pages containing at most resultsPerPage entries. During the diversity scan for one page, a listing whose rating is at least highScoreThreshold may be selected while that provider has appeared fewer than highScorePerProviderPageLimit times on the page. Every lower-rated listing uses a limit of one selected listing for its provider.
Build each page as follows:
Scan the remaining rows in their current order. Select a row when its provider is below the applicable limit above; otherwise defer it. Stop when the page is full or every remaining row has been scanned.
If the scan ends before the page is full, append the earliest deferred rows in order until the page is full or no rows remain. This padding step may exceed the diversity-scan limits.
Remove the selected rows. All unselected rows keep their relative order before the next page is built.
Return every selected original five-field CSV string unchanged in page order. Insert an empty string between consecutive pages, but not after the final page.

Function
paginate(resultsPerPage: int, highScoreThreshold: double, highScorePerProviderPageLimit: int, results: String[]) → String[]

Examples
Example 1
resultsPerPage = 4
highScoreThreshold = 4.8
highScorePerProviderPageLimit = 2
results = ["1,L1,4.9,100.00,San Francisco","1,L2,4.8,120.00,Oakland","2,L3,4.7,80.00,San Jose","3,L4,4.6,90.00,Oakland","1,L5,4.9,110.00,Berkeley","2,L6,4.9,85.00,San Jose","4,L7,4.5,75.00,Oakland"]
return = ["1,L1,4.9,100.00,San Francisco","1,L2,4.8,120.00,Oakland","2,L3,4.7,80.00,San Jose","3,L4,4.6,90.00,Oakland","","1,L5,4.9,110.00,Berkeley","2,L6,4.9,85.00,San Jose","4,L7,4.5,75.00,Oakland"]
Provider 1 contributes two qualifying high-rated listings to page one. All five CSV fields, including consultation fee and city, are returned unchanged.
Example 2
resultsPerPage = 3
highScoreThreshold = 4.8
highScorePerProviderPageLimit = 2
results = ["1,A,4.8,100.00,A","1,B,4.8,110.00,A","1,C,4.7,120.00,A"]
return = ["1,A,4.8,100.00,A","1,B,4.8,110.00,A","1,C,4.7,120.00,A"]
A rating equal to the threshold qualifies. After two provider-1 listings are selected, the lower-rated third row is deferred and then used as deterministic padding.
Example 3
resultsPerPage = 2
highScoreThreshold = 4.9
highScorePerProviderPageLimit = 2
results = ["1,A,4.9,100.00,A","1,B,4.0,110.00,A","2,C,4.0,90.00,B","3,D,4.0,80.00,C"]
return = ["1,A,4.9,100.00,A","2,C,4.0,90.00,B","","1,B,4.0,110.00,A","3,D,4.0,80.00,C"]
The lower-rated second provider-1 row is deferred while provider 2 fills page one. It remains ahead of the unscanned provider-3 row for page two.

Constraints
1 <= resultsPerPage <= 1000.
0.0 <= highScoreThreshold <= 5.0.
1 <= highScorePerProviderPageLimit <= resultsPerPage.
0 <= results.length <= 100000.
Every entry has exactly five comma-separated fields provider_id,listing_id,rating,consultation_fee,city; the rating parses as a number and the complete row must be preserved verbatim.
The input is already ordered by decreasing relevance.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to build each page in two passes. Pass one scans the remaining rows in order and keeps a per-page counter per provider. A row with rating >= threshold is allowed up to highScorePerProviderPageLimit picks for that provider, and every other row is allowed one. Anything over the limit goes to a deferred list. If the page isn't full after the scan, pad from the front of the deferred list, ignoring limits. Then the unselected rows become the next input, order preserved. The pitfall is parsing: split on commas and read the provider from field 0 and the rating from field 2. Another is stopping the scan early, which is correct once the page is full, so the unscanned tail stays ahead of nothing and keeps its order after the deferred rows. Insert an empty string between pages only, never after the last. Done naively with rebuilt lists it's fine for 100000 rows because each page costs about the remaining size, but watch for quadratic blowup when resultsPerPage is 1. If you freeze live, StealthCoder can hand you the loop.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Paginate Provider Listings with Per-Page Diversity 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Maven Clinic reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Paginate Provider Listings with Per-Page Diversity FAQ

How hard is the Maven Clinic pagination problem really?+

Medium at most. There's no clever algorithm, just careful simulation. The difficulty is following the rules exactly: separate limits for high and low ratings, deferral, padding, and order preservation. Code it straight from the statement and test against all three examples.

What's the trick to getting the page-building logic right?+

Keep two lists per page, selected and deferred, plus a provider count map reset each page. Select if the count is under the limit for that row's rating tier. Otherwise defer. After the scan, pad from deferred in order. The remaining rows are deferred plus the unscanned tail.

Does a rating equal to the threshold count as high-rated?+

Yes. The statement says at least the threshold, and Example 2 confirms it with ratings of 4.8 against a 4.8 threshold. Use >= and parse the rating as a double, not a string compare.

Where do people lose points on this one?+

Three spots: forgetting that padding can exceed the diversity limits, putting the empty separator after the final page, and mishandling remaining order so deferred rows land behind unscanned rows. Also handle an empty results array by returning an empty list.

How do I prepare in 48 hours?+

Write a clean simulation loop and run the three examples by hand. Practice splitting CSV rows and tracking a per-page hash map. Then test edge cases: limit equal to page size, all rows from one provider, and resultsPerPage of 1 with a large input for performance.

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

OA at Maven Clinic?
Invisible during screen share
Get it