FastPrepOptimize Discount Selection Under a Point Budget
Problems/Optimize Discount Selection Under a Point Budget

Optimize Discount Selection Under a Point Budget

Palantir logoPalantir● HardINTERNNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Palantir online assessment for intern and new grad roles. The report does not give a limit for exact search or a rule for ties. Our version is about 94% 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 a set of item-specific or category-wide percentage discounts. An item discount costs 2 points, a category discount costs 5 points, and you may spend at most 20 points.

Choose a subset of discounts that maximizes the cart's total rounded savings. For each item, apply its selected item discount first and its selected category discount second. Discounts stack multiplicatively, the total discount on one item is capped at 80%, and the final per-item discount is rounded to the nearest cent with exact half-cent ties going to the nearest even integer.

If several selections produce the same maximum savings, prefer the one using fewer points. If points are also equal, prefer the lexicographically smallest ascending list of original discount indices.

Return an integer array whose first value is the total points used and whose remaining values are the selected original discount indices in ascending order.

Function

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

Examples

Example 1

itemNames = ["Milk"]prices = [500]categories = ["Dairy"]discountTypes = ["item"]discountNames = ["Milk"]percentOff = [20]return = [2, 0]

Selecting discount 0 costs 2 points and saves 100 cents.

Example 2

itemNames = ["Laptop"]prices = [1000]categories = ["Electronics"]discountTypes = ["item", "category"]discountNames = ["Laptop", "Electronics"]percentOff = [70, 50]return = [7, 0, 1]

Selecting both discounts costs 7 points and reaches the 800-cent cap, which is better than either discount alone.

Example 3

itemNames = ["A"]prices = [100]categories = ["X"]discountTypes = ["item", "category"]discountNames = ["A", "X"]percentOff = [80, 80]return = [2, 0]

Either discount alone reaches the 80-cent cap, and selecting both saves no more. The item discount wins because it uses fewer points.

Constraints

  • 1 ≤ itemNames.length = prices.length = categories.length ≤ 100000.
  • 0 ≤ discountTypes.length = discountNames.length = percentOff.length ≤ 20.
  • 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 maximum rounded total savings fits in a signed 64-bit integer.

More Palantir Online Assessment questions

  • Basic Item DiscountsOA · Seen Nov 2026
  • Stacked Item and Category DiscountsOA · 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

  • Bitwise XOR SubsequencesJP Morgan Chase · OAJP Morgan Chase interview questions
  • Bitwise XOR SubsequencesGoldman Sachs · OAGoldman Sachs interview questions
  • Delete K Subsets for Maximum ScoreRubrik · OARubrik interview questions
  • Maximum Index-Weighted Sum with Disjoint SwapsVisa · OAVisa interview questions
  • Pressure-Isolation Shutdown OrderIntuit · OAIntuit interview questions
  • Count Permutations Without Three Equal Parities in a RowGoogle · OAGoogle interview questions
  • Count Divisible PermutationsDeloitte · OADeloitte interview questions
  • Distinct OR Values of Increasing SubsequencesScale AI · OAScale AI interview questions
  • Count Good SubsequencesFlexport · OAFlexport interview questions
  • Sum of Compressed Number for All SubarraysWells Fargo · OAWells Fargo 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 int[] optimizeDiscounts(String[] itemNames, int[] prices, String[] categories, String[] discountTypes, String[] discountNames, int[] percentOff) {
        // write your code here
    }
}
Checking account…