[개발자매일영어] Anagrams - Cracking Coding Interview

in #kr-dev6 years ago

이번에는 Anagrams에 대한 내용 입니다.

개발자매일영어는 당분간은 Cracking Coding Interview의 저자로 유명한 Gayle Laakmann McDowell저자의 강좌를 지속적으로 공부해보도록 하겠습니다.
전체 분량은 너무 길어서 주요부분 한 두 군데만 1분 이하로 발췌하여 mp3파일로 만들고 있습니다.
즉 한 주제당 1분 이하 분량의 mp3파일이 한 두개씩 제공되겠습니다. 나머지 부분은 리스닝 연습 하시면 되겠습니다.
이번에는 따라하기 쉽도록 최대한 짧게 잘랐습니다.

공부하는 4단계 방법은 아래와 같습니다.

  1. 1분 이하 분량을 번역
  2. 전체 듣기 두번
  3. 문장 듣고 따라 말하기 두번
  4. 한국어로 듣고 영어로 말하기 한번 => 제일 중요 합니다!!!!
    하루에 한시간 이상 들으면서 말하기 연습하면 좋을 것 같습니다.
    *** 개발자 매일 영어는 제가 개인적으로 공부하기 위해 만든 mp3파일을 혹시 다른 분에게도 도움이 될까 해서 공유하고 있는 것입니다. 제 목소리도 포함되어 있고, 부족한 영어 실력으로 번역한 것이라 잘못되었을 수도 있습니다. 제 목소리에 놀라지 마시고 이상한 부분은 댓글로 알려 주시면 감사하겠습니다. ***

mp3 파일 다운로드: https://drive.google.com/open?id=1UhXGpxvUJatHkh2JNY3JoWW6FQbVlIGa

----- mp3 script -----
You have two strings, just with the lowercase characters, "a" to "z", how many characters would you have to remove from the two strings to make them anagrams?
So, anagrams as you might remember are just permutations of a word, so rearrangements of the words.
So for two words to be anagrams it means that they have the same characters but just
in different orders.
So for example you have the input hello and billion you'd have to remove six characters total - the "h" and the "e" from hello and the "b" "i" "i" "n" from billion and then that will leave you with "l" "l" and "o" in each of the two strings.
So given two arbitrary strings how many characters would you have to remove from each string to make them anagrams?
Well anagrams are.. ...they have the same exact characters and the same number of each characters, without the order mattering.
So if you want to know...if you have just the string "a" "a" "a" and "a" and you want to make those two things anagrams of each other, you'd have to remove 2 a's from the first string.
So if we have a whole bunch of characters it's the same process essentially, if we want to make two strings anagrams of each other, count how many times each character appears in each string and then look at the difference between those values.

-- 번역 예 (직접번역 해보세요) --
a에서 z까지 소문자로된 두개의 문자열이 있습니다. 두 문자열에서 얼마나 많은 문자들을 제거해야만 anagrams가 될까요? 기억하실지도 모르지만 anagrams는 한 단어의 순열입니다. 단어들의 재배열들이죠. 두 단어가 anagrams란 것은 두 단어가 같은 문자들을 가지지만 단지 순서가 다르다는 것입니다.
예를들면, hello와 billion을 입력 받고 h와 e를 hello에서 b i i n을 billion에서 모두 6개의 문자들을 제거하면 각각의 두 문자열에서 l l과 o 가 남을 것입니다. 주어진 임의의 문자열들에서 anagrams를 만들기 위해 얼마나 많은 문자들을 각각의 문자열에서 제거해야할까요?
anagrams는 순서와 관계없이 똑같은 문자들과 똑같은 문자 갯수를 가진 문자열들입니다.
a a a와 a의 두개의 문자열이 있고 그것들을 각각 두개의 anagrams로 만들고 싶다면 첫째 문자열에서 두개의 a를 제거해야 합니다.
우리가 엄청 많은 문자들을 가지고 있어도 처리 방법은 기본적으로 같습니다. 우리가 두개의 문자열 anagrams를 각각 만들려고 한다면 얼마나 많이 각 문자가 각 문자열에서 나타나는지 세고 그리고 그 값들 간에 다른점을 찾으면 됩니다.

Sort:  

Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://stackoverflow.com/questions/15045640/how-to-check-if-two-words-are-anagrams