Skip to content · ⁨Bỏ qua nội dung⁩

Group anagrams · ⁨Nhóm 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.

Tiếng Việt

Nhóm anagram

Hai từ là anagram nếu chúng sử dụng đúng cùng các chữ cái, như eat và tea. Nhóm các anagram lại với nhau và trả về một danh sách các nhóm.

Mẹo: sắp xếp các chữ cái của mỗi từ để tạo ra một khóa — eat và tea đều trở thành aet. Các từ có cùng khóa thuộc về cùng một nhóm. Sử dụng bảng từ từ khóa → danh sách các từ, và nhớ thứ tự các khóa xuất hiện lần đầu.

Log in or create account · ⁨Đăng nhập hoặc tạo tài khoản⁩

IGCSE, A-Level & AP