PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Amazon

Count partitions and equal-cost packages

Last updated: Mar 29, 2026

Quick Overview

This question evaluates string-processing and combinatorial counting skills, including tracking distinct-character occurrences across contiguous partitions and using frequency-based pairing logic on arrays to form equal-cost packages.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Count partitions and equal-cost packages

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

##### Question Given a string itemCategories, count the number of ways to partition it into exactly two contiguous non-empty substrings (a prefix and a suffix) such that the number of distinct characters appearing in both substrings is greater than k. Given an array itemCosts representing item costs, determine the maximum number of packages that can be created so that each package contains at most two items, all packages have the same total cost, and each item is used in at most one package.

Quick Answer: This question evaluates string-processing and combinatorial counting skills, including tracking distinct-character occurrences across contiguous partitions and using frequency-based pairing logic on arrays to form equal-cost packages.

Related Interview Questions

  • Count Connected Components in an Undirected Graph - Amazon (medium)
  • Find Unique Target-Sum Pairs - Amazon (easy)
  • Find Valid IP Addresses in Files - Amazon (medium)
  • Implement Optimal Bucket Batching - Amazon (hard)
  • Implement Cache and Rotate Matrix - Amazon (medium)
Amazon logo
Amazon
Aug 4, 2025, 10:55 AM
Software Engineer
Take-home Project
Coding & Algorithms
5
0
Question

Given a string itemCategories, count the number of ways to partition it into exactly two contiguous non-empty substrings (a prefix and a suffix) such that the number of distinct characters appearing in both substrings is greater than k. Given an array itemCosts representing item costs, determine the maximum number of packages that can be created so that each package contains at most two items, all packages have the same total cost, and each item is used in at most one package.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.