Skip to content

Practice Rearrange Characters to Make Target String

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2287
LeetCode Problem

Rearrange Characters to Make Target String

Problem Statement

You are given two 0-indexed strings s and target. You can take some letters from s and rearrange them to form new strings. Return the maximum number of copies of target that can be formed by taking letters from s and rearranging them. Example 1: Example 2: Example 3: Constraints: Note: This question is the same as 1189: Maximum Number of Balloons.

Source: Rearrange Characters to Make Target String on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "ilovecodingonleetcode", target = "code"
Output
2

# Example 2

Input
s = "abcba", target = "abc"
Output
1

# Example 3

Input
s = "abbaccaddaeea", target = "aaaaa"
Output
1

Constraints

1 <= s.length <= 100
1 <= target.length <= 10
s and target consist of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Rearrange Characters to Make Target String.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.