Skip to content · ⁨Lompat ke konten⁩

Group anagrams · ⁨Kelompokkan anagram⁩

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.

Bahasa Indonesia

Kelompokkan anagram

Dua kata adalah anagram jika menggunakan huruf yang persis sama, seperti eat dan tea. Kelompokkan anagram bersama dan kembalikan list kelompok-kelompoknya.

Triknya: urutkan huruf dari setiap kata untuk membuat kunci — eat dan tea keduanya menjadi aet. Kata dengan kunci yang sama masuk dalam kelompok yang sama. Gunakan dictionary dari kunci → list kata, dan ingat urutan kemunculan kunci pertama.

Log in or create account · ⁨Masuk atau buat akun⁩

IGCSE, A-Level & AP