Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Count character frequencies of the first string using a hash map. Then subtract frequencies using the second string. If any character count goes below zero or a character is missing, the strings are not anagrams. Equal lengths with matching frequencies confirms an anagram.
Two strings are anagrams if and only if they have identical character frequency distributions. Incrementing for one string and decrementing for the other detects any mismatch.
Updated Feb 2026