12 lines
316 B
Python
12 lines
316 B
Python
class Solution:
|
|
def rearrangeCharacters(self, s: str, target: str) -> int:
|
|
s_set = {}
|
|
for i in s:
|
|
s_set[i] = s_set.get(i, 0) + 1
|
|
|
|
t_set = {}
|
|
for j in target:
|
|
t_set[j] = t_set.get(j, 0) + 1
|
|
|
|
return min(s_set.get(ch, 0) // t_set[ch] for ch in t_set)
|