Reported August 2026
Capital One

Highest Version B Viewing Week

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

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

The Capital One OA reported in August 2026 gives you a SQL problem that looks fussy but is really a grouping question: find the Monday-to-Sunday week with the most Version B viewing time. The input is capped at 2000 rows, so nothing here is about speed. It's about getting week boundaries right and not counting partial weeks. If you blank on the date math mid-assessment, StealthCoder runs invisibly on your desktop and can hand you a working query as a safety net.

The problem

A video-streaming company compares two versions of its ads. The experiment_metrics table contains one aggregated row for every date and time slot in a calendar month.
Find the complete Monday-to-Sunday week with the greatest total user_time_spent_version_b_in_mins. Sum that column across every time slot and all seven dates in the week.
Weekly selection
A week is complete only when all seven calendar dates from Monday through Sunday occur in the input.
Ignore partial weeks at the beginning or end of the month.
If several complete weeks have the same greatest total, choose the earliest Monday.
Return exactly one row with week_start and week_end.

Tables
experiment_metrics: id PK (Integer), metric_date (Date), time_slot (Text), total_user_time_spent_in_mins (Integer), total_ads_watched_in_mins (Integer), ads_clicked (Integer), user_time_spent_version_b_in_mins (Integer), ads_watched_version_b_in_mins (Integer), ads_clicked_version_b (Integer)

Constraints
experiment_metrics contains every date in one calendar month.
Every date has the same positive number of distinct time slots.
id values are unique.
At least one complete Monday-to-Sunday week exists.
All minute and click counts are non-negative signed 64-bit integers.
Every weekly sum fits in a signed 64-bit integer.
A testcase contains at most 2000 rows.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to assign every row a week_start, group by it, and keep only groups with seven distinct dates. Compute week_start by subtracting the weekday offset from metric_date, so Monday maps to itself and Sunday maps back six days. Then week_end is week_start plus 6. Use COUNT(DISTINCT metric_date) = 7 in HAVING to drop partial weeks at the month edges. Sum user_time_spent_version_b_in_mins per group, ORDER BY that sum DESC, week_start ASC, and LIMIT 1. The pitfalls: summing the wrong column (the non-version-B total is right there), forgetting the tie-break on earliest Monday, and relying on a weekday function whose first day of week differs by dialect. Check how your SQL engine numbers weekdays before you trust the offset. If the dialect quirks eat your time, StealthCoder is the hedge during the live OA.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Highest Version B Viewing Week 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 would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Capital One reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Highest Version B Viewing Week FAQ

What's the trick in the Highest Version B Viewing Week problem?+

Turn each date into its Monday, group by that Monday, and filter to groups with seven distinct dates. Sum the version B time column, sort descending, break ties with the earliest week_start, and return one row. The rest is dialect-specific date arithmetic.

How do I exclude partial weeks?+

Use HAVING COUNT(DISTINCT metric_date) = 7 after grouping by week_start. Partial weeks at the start or end of the month will have fewer than seven dates. Distinct matters because each date has multiple time slots, so a plain COUNT would be inflated.

How do I compute the Monday of a date?+

Subtract the number of days since Monday from the date. The function depends on the dialect. Some engines return Sunday as 0 or 1, others Monday as 0 or 1. Test it on a known Sunday and Monday before you build the query on it.

Which column should I sum?+

Sum user_time_spent_version_b_in_mins only. The table also has total_user_time_spent_in_mins and ads columns that look similar. Picking the wrong one gives a plausible but wrong answer, so reread the column name before submitting.

How do I prepare for this in 48 hours?+

Write three small queries on date bucketing: group by week, filter groups with HAVING, and rank with ORDER BY plus LIMIT 1. Practice the tie-break. This question needs no window functions, so keep the query short and readable.

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

OA at Capital One?
Invisible during screen share
Get it