Applied AI Engineer (LLM) coding learning path Level 1 This level · 2 of 9

Valid Anagram

Easy Hash Table String

Problem

Given two strings, decide whether one is a rearrangement of the other's letters.

Original: LeetCode 242: Valid Anagram.

Examples

Example 1

Input`s = "anagram", t = "nagaram"`
Output`true`

Example 2

Input`s = "rat", t = "car"`
Output`false`

Example 3

Input`s = "a", t = "ab"`
Output`false`

Constraints

  • 1 <= s.length, t.length <= 5 * 10^4
  • s and t consist of lowercase English letters.

Hints

Solution

Tried it yourself? The approach, complexity, and code stay hidden until you choose.

Sources (2)
  1. LeetCode 242: Valid Anagramleetcode.com
  2. Java SE 17 API: String.codePointsdocs.oracle.com
Previous
Next