Files
cpp-flashcards/org/study_deck_02/dsa/arrays-hashing/0242-valid-anagram.org
T
tomatocream 1dec88aaf2 feat: populate note files with problem descriptions and code stubs
Add populate-notes.mjs that fetches problem descriptions and
Python/C++ code stubs from LeetCode's GraphQL API. Populated
all 197 NeetCode 150 note files with:
- Problem description (examples, constraints)
- Python code stub (function signature)
- C++ code stub (function signature + includes)

API responses cached in leetcode/.cache/leetcode/ for instant re-runs.
2026-06-01 17:22:07 +08:00

891 B

TODO 0242. Valid Anagram   easy

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

Example 1:

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

Output: true

Example 2:

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

Output: false

Constraints:

  • 1 <= s.length, t.length <= 5 * 10^{4}
  • s and t consist of lowercase English letters.

Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case?

TODO Approach

Write your approach here.

TODO Python

class Solution:
    def isAnagram(self, s: str, t: str) -> bool:

TODO C++

class Solution {
public:
    bool isAnagram(string s, string t) {
        
    }
};