Find Maximum Packages

Problem Overview

  • Given item costs, find the maximum number of packages where each package has at most 2 items and all packages share the same total cost; each item can be used once.
  • Input: int array cost of size n; Output: int maximum number of such packages.
  • Constraints: 1 ≤ n ≤ 2×10^5, 1 ≤ cost[i] ≤ 2000.
  • Real-world context: Amazon marketplace inventory bundling to enhance sales.
  • From Amazon interviews; a coding interview problem and interview question.

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: