Challenge Statement

  • Given two strings s and t, return True if t is an anagram of s, and False otherwise.
  • An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
  • This challenge corresponds to LeetCode #242.


  • 1 <= len(s), len(t) <= 5 * 104
  • s and t consist of lowercase English letters.

Example 1:

Input: s = "anagram", t = "nagaram"

Output: True

Example 2:

Input: s = "rat", t = "car"

Output: False


Below is my solution and some test cases. This solution has a linear time complexity O(n+n) and a linear space complexity O(n+n), where n is the length of the input string s.

%d bloggers like this: