Baseline Strings · Easy O(n) · O(1)
Two depots transmit their part-code lists at the end of a shift, and the receiving hub must confirm the second manifest is a rearrangement of the first — identical part codes with identical multiplicities, merely shuffled. Any mismatched count, even by a single unit, flags the shipment for manual audit. Lengths that disagree make the check fail instantly.
Input: Two strings s and t.
Output: true when t is an anagram of s (same letters with the same frequencies), false otherwise.
0 <= s.length, t.length <= 5 * 10^4s and t consist of lowercase English lettersInput: {"s":"anagram","t":"nagaram"}
Output: true
Both manifests use each letter exactly as often as the other — a perfect rearrangement.
Input: {"s":"rat","t":"car"}
Output: false
Same length, but the letter inventories differ: an r appears where a c should be.