FastPrepItems Purchase (For Java Backend Engineer)
Problems/Items Purchase (For Java Backend Engineer)

Items Purchase (For Java Backend Engineer)

PayPal logoPayPal● MediumOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

n items where the price of the ith item is price[i]. A frequent customer has m discount coupons. If x discount coupons are used on the ith item, its price is reduced to the integer floor(price(i) / 2^x), e.g. floor(3/2^1) = floor(1.5) = 1. Find the minimum amount needed to purchase all the items of the shop using at most m coupons.

Function

findMinimumPrice(price: int[], m: int) → int

Complete the function findMinimumPrice in the editor below.

findMinimumPrice has the following parameters:

  1. int price[n]: the original prices of the items
  2. int m: the number of discount coupons

Returns int: the minimum amount needed to purchase all items

Examples

Example 1

price = [2, 4]m = 2return = 3

The optimum solution:

  • Purchase item 1 for 2.
  • Use 2 coupons on item 2, so the discounted price is 4/2^2 = 4 / 4 = 1.

The amount required = 2 + 1 = 3.

Constraints

  • 1 <= n <= 10^5
  • 0 <= m <= 10^9
  • 1 <= price[i] <= 10^9

More PayPal interview questions

  • Minimum Cost to Merge Values into OneOA · Seen Nov 2026
  • Per-User Sliding-Window Rate LimiterOA · Seen Nov 2026
  • Total Cost Against the Lowest Earlier PriceOA · Seen Nov 2026
  • Find Minimum Price to SpendOA · Seen Oct 2024
  • Modify ArrayOA · Seen Jun 2024
  • Count User Logins 🌿 (Singapore)OA · Seen Mar 2024
  • Similar Password 🪴 (Singapore)OA · Seen Mar 2024
  • Can the Singer Perform the Song?PHONE SCREEN · Seen Jul 2025

Similar questions at other companies

  • Task SchedulerAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Maximum K-Star SumC3.ai · OAC3.ai interview questions
  • Maximum Sum of a K-StarMicrosoft · OAMicrosoft interview questions
  • Maximum ScoreNVIDIA · OANVIDIA interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Task SchedulingJP Morgan Chase · OAJP Morgan Chase interview questions
  • Decreasing SubsequencesGoogle · OAGoogle interview questions
  • Get Maximum AmountIBM · OAIBM interview questions
  • Optimize TikTok Reels ViewingTikTok · OATikTok interview questions
  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions

PayPal interview experiences

  • PayPal SWE Intern OA Questions: 1 Experience
All PayPal interview questionsSee PayPal hiring insights
Saved
class Solution {
    public int findMinimumPrice(int[] price, int m) {
      // write your code here
    }

}
Checking account…