Anagram Check

Problem Given two strings, determine whether they are anagrams of each other (contain exactly the same characters with the same frequencies).

Input / Output

  • Input: two strings s and t
  • Output: boolean — true if t is an anagram of s

Constraints

  • Clarify with the interviewer: case sensitivity, whitespace, and Unicode vs. ASCII
  • Lengths up to 10^5; O(n) time expected

Example

  • s = "listen", t = "silent" → true
  • s = "rat", t = "car" → false
  • Length mismatch is an immediate false
asked …
LeaderboardSalaryAccount