Anagram Checker Plus
Medium
string
anagram
frequency-counting
hash-map
Problem Description
Given two strings, determine if they are anagrams of each other. Additionally, find the minimum number of character deletions required to make them anagrams if they are not already anagrams.
Input Format
Two strings on separate lines.
Output Format
If anagrams: "ANAGRAM". If not: "NOT ANAGRAM X" where X is minimum deletions needed.
Constraints
• 1 ≤ string length ≤ 1000
• Strings contain only lowercase letters
• Case-sensitive comparison
• Count minimum deletions from both strings
• Empty strings are anagrams
Sample Input/Output
Input:
listen silent
Output:
ANAGRAM
Explanation
"listen" and "silent" contain the same characters with same frequencies, so they are anagrams.
Solution Hints
80
Points
Points
2000ms
Time Limit
Time Limit
128MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now