Loading...
Loading...
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
An Anagram is a word formed by rearranging the letters of another, using all the original letters exactly once.
Input: Strings s and t.
Output: Boolean.
Input: s = "anagram", t = "nagaram" → Output: true
Input: s = "rat", t = "car" → Output: false
s, decrement for t. If any non-zero, false. Time: O(n), Space: O(1) (26 letters).sorted(s) == sorted(t). Time: O(n log n).len(s) == len(t); if not, immediately return false.1 <= s.length, t.length <= 5 * 10^4 s and t consist of lowercase English letters