How Many Copies of balloon Can Be Assembled?

Quick Overview

How Many Copies of balloon Can Be Assembled?. Rearrange letters from text to assemble as many separate copies of balloon as possible.

How Many Copies of balloon Can Be Assembled?

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem Rearrange letters from text to assemble as many separate copies of `balloon` as possible. Each occurrence in text can be used at most once across all copies. Return the maximum copy count. ```cpp class Solution { public: int maxNumberOfBalloons(string text); }; ``` ### Examples **Example 1:** ```text Input: text = "balloonballoon" Output: 2 Explanation: The input provides exactly two full copies. ``` **Example 2:** ```text Input: text = "balon" Output: 0 Explanation: A copy needs two l letters and two o letters; only one of each is present. ``` ### Constraints - text contains 1 to 10000 lowercase English letters. ### Contract considerations The target word is exactly balloon; this is not an ordered-subsequence requirement. ```hint Read the boundary condition Can letter occurrences be reused between separate copies, and does their original order limit assembly? ``` ### Boundary reminders The target word is exactly balloon; this is not an ordered-subsequence requirement.

Overview: How Many Copies of balloon Can Be Assembled?. Rearrange letters from text to assemble as many separate copies of balloon as possible.

Amazon logo
Amazon
Source window: 0–6 months · as of Oct 21, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

Rearrange letters from text to assemble as many separate copies of balloon as possible. Each occurrence in text can be used at most once across all copies. Return the maximum copy count.

class Solution {
public:
    int maxNumberOfBalloons(string text);
};

Examples

Example 1:

Input: text = "balloonballoon"
Output: 2
Explanation: The input provides exactly two full copies.

Example 2:

Input: text = "balon"
Output: 0
Explanation: A copy needs two l letters and two o letters; only one of each is present.

Constraints

  • text contains 1 to 10000 lowercase English letters.

Contract considerations

The target word is exactly balloon; this is not an ordered-subsequence requirement.

Boundary reminders

The target word is exactly balloon; this is not an ordered-subsequence requirement.