Problem · Array
Minimum Image Processing Cost
Learn this problemProblem statement
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) → intExamples
Example 1
filterCost = [2,3,4]startDay = [1,1,2]endDay = [2,3,4]discountPrice = 6return = 21For filterCost = [2, 3, 4], startDay = [1, 1, 2], endDay = [2, 3, 4], and discountPrice = 6, the individual filtering costs by day are:
| 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 |
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.
More Citadel problems
- Minimum Changes for a Periodic PalindromeOA · Seen Jul 2026
- Minimum Path Sum to Target in Binary TreePHONE SCREEN · Seen Apr 2026
- Minimum Time to Process RequestsOA · Seen Mar 2026
- Process SchedulingOA · Seen Mar 2026
- Social Media SuggestionsSeen May 2025
- Best Sum Downward Tree PathSeen May 2025
- Price CheckSeen Feb 2025
- Palindromic Substrings (LC 647 :)Seen Jan 2025