2287. Rearrange Characters to Make Target String

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2287

class Solution:
    def rearrangeCharacters(self, s: str, target: str) -> int:
        cnt1 = Counter(s)
        cnt2 = Counter(target)
        return min(cnt1[c] // v for c, v in cnt2.items())