https://www.hackerrank.com/challenges/making-anagrams/problem?isFullScreen=true
Making Anagrams | HackerRank
How many characters should one delete to make two given strings anagrams of each other?
www.hackerrank.com
잊지 말자
discrad - set()에서 사용 가능(str, list 불가능)
remove - str에서 불가능
str에서 할려면 replace를 써야하는데 모든 단어를 다 바꾸므로 불가능(횟수를 정할순 있음)
그럴꺼면 그냥 list로 바꾸는게 속편하다
def makingAnagrams(s1, s2):
list_s1 = []
list_s2 = []
for i in s1:
list_s1.append(i)
for j in s2:
list_s2.append(j)
for s in list_s1:
if s in list_s2:
list_s2.remove(s)
same = len(s2) - len(list_s2)
return len(s1) + len(s2) - same*2'파이썬 코딩테스트 > 해커랭크' 카테고리의 다른 글
| HackerRank / Two Strings / Python (0) | 2022.01.02 |
|---|---|
| HackerRank / Anagram / Python (0) | 2021.12.31 |
| HackerRank / Beautiful Binary String / Python (0) | 2021.12.31 |
| HackerRank / Palindrome Index / Python (0) | 2021.12.30 |
| HackerRank / Sherlock and the Valid String / Python (0) | 2021.12.28 |