Skip to content

Commit 89bc7b6

Browse files
authored
Create minimum-number-of-steps-to-make-two-strings-anagram-ii.py
1 parent 96c14da commit 89bc7b6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
import collections
5+
6+
7+
# freq table
8+
class Solution(object):
9+
def minSteps(self, s, t):
10+
"""
11+
:type s: str
12+
:type t: str
13+
:rtype: int
14+
"""
15+
cnt1, cnt2 = collections.Counter(s), collections.Counter(t)
16+
return sum((cnt1-cnt2).itervalues())+sum((cnt2-cnt1).itervalues())

0 commit comments

Comments
 (0)