Rearrange Characters to Make Target String
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.
Note: This question is the same as 1189: Maximum Number of Balloons.
Example 1
Input
s = "ilovecodingonleetcode", target = "code"Output
2We can make at most two copies of "code" from the available letters in
s, so we return 2.Example 2
Input
s = "abcba", target = "abc"Output
1We can make one copy of "abc", but cannot make a second because the letter
c cannot be reused.Constraints
- 1 <= s.length <= 100
- 1 <= target.length <= 10
- s and target consist of lowercase English letters.