Practice arena
C++17·2 s·128 MB
LinearFoundation

Anagram check

Determine whether two lowercase English strings contain the same characters with exactly the same frequencies.

Input

  • The first line contains T.
  • Each case contains two lowercase strings s and t separated by a space.

Output

Print YES when the strings are anagrams; otherwise print NO.

Technique

fixed frequency array

Target

O(n) time · O(1) alphabet space

Constraints & sample
  • 1 ≤ |s|, |t| ≤ 200,000
  • The total input length is at most 400,000
  • Strings contain only a through z

Sample input

3
listen silent
rat car
aabb bbaa

Expected output

YES
NO
YES
Review the concept

Before you submit

  • Test the smallest valid input and one awkward edge case.
  • Keep the solution within O(n) time · O(1) alphabet space.
  • Match spacing and line breaks exactly before checking 8 hidden cases.
main.cpp
Draft saved locally · 394 / 30,000
Ln 1, Col 1Spaces: 4UTF-8LFC++17

Visible testcases

Editable and stored only in this browser. Hidden judge cases never change.

Checking your session…

Run checks Sample · Submit checks 8 hidden cases

Run the sample first, then send your solution through 8 hidden cases.

Code runs in an isolated Judge0 environment. Drafts and custom visible cases stay on this device; submission metadata and progress sync to MongoDB.