Array & Hashing
74. Valid Anagram
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
Examples
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
sandtconsist of lowercase English letters
Follow-up
What if the inputs contain Unicode characters? How would you adapt your solution to handle such a case?
from collections import Counter
s: str = "antena"
t: str = "atenea"
if Counter(s) == Counter(t):
print(True)
else:
print(False) Keyboard shortcuts
← h Previous problem
→ l Next problem
Esc Back to index
? Toggle this help