AO
Back

Min Cost Image Processing with Daily Discount (OA)

OAAsync OALast reported July 2025Low Frequency

Problem Overview

Reported by a Citadel Software Engineer intern (US) candidate as the second of two problems in a 75-minute round.

Input: an integer n, integer arrays filterCost, startDay and endDay (each of length n), and an integer discountPrice.

You need to process n images. Processing image i costs filterCost[i] per day, and image i must be processed on every day from startDay[i] to endDay[i].

Every day you may use the discount once. If you use it, processing all the images that day costs discountPrice.

Return the minimum cost to process all n images, modulo 10^9 + 7.

Example

n = 3
filterCost = [2, 3, 4]
startDay   = [1, 1, 2]
endDay     = [2, 3, 4]
discountPrice = 6

Day  Images     Total cost
1    [1, 2]     2 + 3 = 5
2    [1, 2, 3]  2 + 3 + 4 = 9
3    [2, 3]     3 + 4 = 7
4    [3]        4

Use the discount on day 2 and day 3  =>  5 + 6 + 6 + 4 = 21

Notes and things to confirm

  • The example settles two points: endDay is inclusive (image 3 runs from day 2 to day 4 and is paid on day 4), and a discounted day costs discountPrice in total, not per image (day 2 has three images and costs 6).
  • The report gives no bounds on n, the costs, discountPrice or the day numbers. Ask for them: they decide whether you can afford to visit every day.

Approach Trade-offs

Approaches actually attempted in reports — including ones that lost candidates time. Pick deliberately.
ApproachNotes
Per-day totals arrayPosted in a reply: add each image's cost to every day it covers, then pay min(day total, discountPrice) per day. O(n * D) time and O(D) space for D days; simple, but depends on the day numbers being small, which the report does not state.

What Reports Emphasize

Why people fail: The candidate solved neither of the two problems within the 75 minutes, although they felt the problems were not hard.

Practice

Write your own against 8 test cases, or read the worked solution — approach, complexity, and code that runs.

Prepping for Citadel with friends?

Send them this page. It is free to read, no account needed.

More Citadel Questions

Free preview

Every question in the Citadel catalog gets this depth

What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 62 Citadel questions, refreshed monthly from new candidate reports.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Citadel · OA · Reported 1× across candidate reports
Is this helpful?