PythonEasyHashing10 min

Check whether two strings are anagrams

Compare exact ASCII characters, including spaces and case. Empty strings are valid. Interviewers use this problem to assess compare character counts rather than sorted strings.

Input

Two lines, one string per line.

Output

Print true or false in lowercase.

Constraints

0 <= each length <= 100000.

Example

Input

listen
silent

Output

true

Example 2 input

a a
aa 

Output

true

Spaces count as characters, not separators.

Public test cases (2)

  • Input

    listen
    silent

    Expected output

    true
  • Input

    rat
    car

    Expected output

    false
Hints (2)
  1. Identify the state needed to avoid repeated work.
  2. Compare character counts rather than sorted strings.

Target complexity: time O(n + m) · space O(k), where k is the number of distinct characters

Your solution

Checking runner availability…

Reference solution

Sign in for solution
All Python programs