728x90
https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram/
class Solution:
def minSteps(self, s: str, t: str) -> int:
step = 0
dic_s = {}
for n in s:
if dic_s.get(n, None) is None:
dic_s[n] = 1
else:
dic_s[n] += 1
for key, value in dic_s.items():
sub = value - t.count(key)
if sub > 0:
step += sub
return step
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 2744. Find Maximum Number of String Pairs (0) | 2024.02.26 |
---|---|
[Leetcode] 2103. Rings and Rods (1) | 2024.02.25 |
[Leetcode] 2913. Subarrays Distinct Element Sum of Squares I (0) | 2024.02.24 |
[Leetcode] 2956. Find Common Elements Between Two Arrays (0) | 2024.02.23 |
[Leetcode] 804. Unique Morse Code Words (0) | 2024.02.23 |