1347. Minimum Number of Steps to Make Two Strings Anagram
Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 82% Topics: Hash Table, String, Counting
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
import collections
class Solution(object):
def minSteps(self, s, t):
"""
:type s: str
:type t: str
:rtype: int
"""
diff = collections.Counter(s) - collections.Counter(t)
return sum(diff.itervalues())
Solution from kamyu104/LeetCode-Solutions · MIT