Reported July 2026
Citadelprefix sum

Minimum Image Processing Cost

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

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

Citadel reported this one in July 2026, and the first-attempt mistake is easy to make. Most people see 'minimum cost' and reach for dynamic programming. You have an OA coming up, so here's the shortcut. Each day is independent. The discount is a flat price for all images on a day, so you never need to plan across days. It's a difference-array sweep plus a per-day min. If you blank on the setup, StealthCoder runs invisibly during the live assessment and gives you the solution as a backup.

The problem

You must process n images. Image i requires a filter on every day from startDay[i] through endDay[i], inclusive, and filtering that image costs filterCost[i] per day.
An exclusive offer allows you to apply a filter to all n images for discountPrice on a day. Determine the minimum total cost of processing all images, and return that cost modulo 10^9 + 7.

Function
getMinProcessingCost(filterCost: int[], startDay: int[], endDay: int[], discountPrice: int) → int

Examples
Example 1
filterCost = [2,3,4]
startDay = [1,1,2]
endDay = [2,3,4]
discountPrice = 6
return = 21
For filterCost = [2, 3, 4], startDay = [1, 1, 2], endDay = [2, 3, 4], and discountPrice = 6, the individual filtering costs by day are:
Daily individual filtering costsDayImagesTotal cost
1[1, 2]2 + 3 = 5
2[1, 2, 3]2 + 3 + 4 = 9
3[2, 3]3 + 4 = 7
4[3]4
Using the all-images offer for 6 on days 2 and 3 is optimal. The final cost is 5 + 6 + 6 + 4 = 21, so its value modulo 10^9 + 7 is 21.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: for each day, compute the sum of filterCost for images active that day, then add min(dailySum, discountPrice) to the total. Build the daily sums with a difference array: add filterCost[i] at startDay[i], subtract it at endDay[i]+1, then take a running prefix sum. The pitfall is the modulo. Take the min on the true values first, then reduce mod 10^9+7. Comparing already-reduced numbers gives wrong answers. Use 64-bit integers for sums, since costs times image counts can overflow 32 bits. Another trap is looping over every day for every image, which is O(n * range) and times out when day ranges are huge. If the ranges are very large, sort the event points instead of allocating an array. If your head goes blank mid-assessment, StealthCoder can supply the sweep as a hedge.

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 Minimum Image Processing Cost 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 Citadel's OA.

Citadel 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.

Minimum Image Processing Cost FAQ

What's the trick in Minimum Image Processing Cost?+

Days are independent. For each day, pay the lesser of the sum of active filter costs or the discountPrice. Compute active sums efficiently with a difference array and a prefix sum. No DP is needed, which is what trips people up.

How hard is this problem really?+

Easy to medium. The logic is one min per day. The difficulty is efficiency and details: the difference array, the endDay+1 decrement, and the modulo applied at the right moment. If you've seen interval-add problems, it's fast.

When do I apply the modulo?+

Only after you compare true values. Take min(dailySum, discountPrice) using the unreduced numbers, accumulate in a 64-bit integer, and apply mod 10^9+7 to the total, or reduce the accumulated total each step after the comparison.

What if the day range is huge?+

If endDay values can be very large, a day-indexed array won't fit. Instead, collect event points (start and end+1), sort them, and process the segments between them. Multiply the segment length by min(segmentSum, discountPrice) for each segment.

How do I prepare for this in 48 hours?+

Practice the difference-array pattern on interval-update problems like Corporate Flight Bookings. Then do a sweep-line variant with sorted events. Run the provided example by hand: days 1 to 4 should produce 5, 6, 6, 4 for 21.

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

OA at Citadel?
Invisible during screen share
Get it