diff --git a/solutions/lc2287.py b/solutions/lc2287.py new file mode 100644 index 0000000..4881099 --- /dev/null +++ b/solutions/lc2287.py @@ -0,0 +1,11 @@ +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)