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. מילים עם אותו מפתח שייכות לאותה קבוצה. השתמש במילון ממפתח → רשימת מילים, וזכור את הסדר שהמפתחים מופיעים לראשונה.

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP