Skip to content · ⁨본문 바로가기⁩

Group anagrams · ⁨아나그램 그룹화⁩

English

Group anagrams

Two words are anagrams if they use exactly the same letters, like eat and tea. Group the anagrams together and return a list of groups.

The trick: sort the letters of each word to make a key — eat and tea both become aet. Words with the same key belong in the same group. Use a dictionary from key → list of words, and remember the order the keys first appear.

한국어

아나그램 그룹화

두 단어가 아나그램이라 함은 정확히 같은 글자를 사용하는 것을 의미하며, 예로 eat과 tea이 있습니다. 아나그램끼리 묶어 그룹의 목록을 반환하십시오.

핵심 전략: 각 단어의 글자를 정렬하여 키를 만듭니다 — eat과 tea은 모두 aet가 됩니다. 동일한 키를 가진 단어는 같은 그룹에 속합니다. 키 → 단어 목록으로 되는 사전(dictionary)을 사용하고, 키가 처음 나타나는 순서를 기억해 두십시오.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP