Items Purchase (For Java Backend Engineer)

Easypaypal

Problem Overview

  • Task: Given n item prices and m discount coupons, find the minimum total cost to buy all items; using x coupons on an item sets its price to floor(price/2^x).
  • Inputs/Outputs: price[n] and m; return the minimal total amount as an int.
  • Constraints: 1<=n<=1e5, 0<=m<=1e9, 1<=price[i]<=1e9.
  • Context: Retail discounting and pricing scenario relevant to backend systems.
  • Company: Asked in Paypal interviews; a coding interview interview question problem.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: