FastPrepStacked Item and Category Discounts
Problems/Stacked Item and Category Discounts

Stacked Item and Category Discounts

Palantir logoPalantir● MediumINTERNFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Palantir online assessment for intern and full-time roles. Our version is about 99% the same as the reported question.

Special thanks: 🌷 A special thank you to a lovely, amazing fren who shared that this question appeared again on November 3, 2026! ٩(ˊᗜˋ*)و ♡ 🧡

You are given a shopping cart and item-specific or category-wide percentage discounts. Each cart item has a name, an integer-cent price, and a category. Each discount has type item or category, a matching name, and a percentage.

For each item, apply its matching item discount first and its matching category discount second. The two discounts stack multiplicatively. For example, 10% off followed by 20% off leaves price * 0.90 * 0.80, so the total discount is 28%.

The total discount on one item cannot exceed 80% of its original price. If the next discount would exceed that limit, apply only enough of it to reach exactly 80%. Ignore unmatched discounts.

Return a three-element array containing the subtotal, total rounded discount, and final total. Compute each item's combined discount without intermediate rounding, cap it at 80%, and then round that final discount to the nearest cent. An exact half-cent tie rounds to the nearest even integer.

Function

calculateStackedDiscountTotals(itemNames: String[], prices: int[], categories: String[], discountTypes: String[], discountNames: String[], percentOff: int[]) → long[]

Examples

Example 1

itemNames = ["Milk"]prices = [500]categories = ["Dairy"]discountTypes = ["item", "category"]discountNames = ["Milk", "Dairy"]percentOff = [10, 20]return = [500, 140, 360]

The stacked price factor is 0.90 * 0.80 = 0.72, so the discount is 140 cents.

Example 2

itemNames = ["Laptop"]prices = [1000]categories = ["Electronics"]discountTypes = ["item", "category"]discountNames = ["Laptop", "Electronics"]percentOff = [70, 50]return = [1000, 800, 200]

The discounts would save 85%, so the per-item cap limits the discount to 800 cents.

Example 3

itemNames = ["A"]prices = [105]categories = ["X"]discountTypes = ["item"]discountNames = ["A"]percentOff = [10]return = [105, 10, 95]

The raw 10.5-cent discount is an exact tie and rounds to the even value 10.

Constraints

  • 1 ≤ itemNames.length = prices.length = categories.length ≤ 100000.
  • 0 ≤ discountTypes.length = discountNames.length = percentOff.length ≤ 100000.
  • 0 ≤ prices[i] ≤ 10^9.
  • 0 ≤ percentOff[i] ≤ 100.
  • Every discount type is exactly item or category.
  • There is at most one item discount per item name and at most one category discount per category.
  • Names and categories are non-empty case-sensitive strings.
  • The subtotal and returned totals fit in a signed 64-bit integer.

More Palantir Online Assessment questions

  • Basic Item DiscountsOA · Seen Nov 2026
  • Optimize Discount Selection Under a Point BudgetOA · Seen Nov 2026
  • Minimize Path ValueOA · Seen Sep 2024
  • No Pairs AllowedOA · Seen Sep 2024
  • REST API: Country CodesOA · Seen Feb 2024
  • Swap ParityOA · Seen Feb 2024
  • Freelance Candidate ReviewOA · Seen Nov 2023
  • Benchmarking Tool ReportOA · Seen Sep 2023
  • Count Fit Records Across PagesOA · Seen Sep 2023
  • Network FormationOA · Seen Sep 2023

Similar questions at other companies

  • Group-Relative Policy AdvantagesAmazon · ONSITE INTERVIEW
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Macaron Order PriceOpenAI · OAOpenAI interview questions
  • Daily Settlement for Long and Short PositionsBelvedere Trading · OA
  • Process Banking OperationsVercel · OA
  • Get Triplet CountIBM · OAIBM interview questions
  • First Completed Mingo LineEpic · OAEpic interview questions

Interview reports that mention this question

  • Palantir FDSE Intern OA and Interviews: 3 Experiences

Palantir interview experiences

  • Palantir FDSE Experienced-Hire Interviews: 5 Experiences
  • Palantir FDSE New Grad OA Questions: 6 Experiences (Part 2 of 2)
  • Palantir FDSE New Grad Interviews: 5 Experiences (Part 1 of 2)
  • Palantir FDSE Karat and Learning: 7 Experiences (Part 2 of 2)
  • Palantir FDSE OA and Interviews: 16 Experiences (Part 1 of 2)
All Palantir interview questionsSee Palantir hiring insights
Saved
class Solution {
    public long[] calculateStackedDiscountTotals(String[] itemNames, int[] prices, String[] categories, String[] discountTypes, String[] discountNames, int[] percentOff) {
        // write your code here
    }
}
Checking account…