Anagram
Learn Anagram (Strings, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What is an Anagram? Two strings are anagrams if one can be rearranged into the other - same characters, same counts, different order. Two classic checks: Sort both strings and compare - O(n log n). Compare frequency counts - O(n), faster since it avoids sorting entirely.