FastPrepValid Anagram
Problems/Valid Anagram

Valid Anagram

AMD logoAMD● EasyINTERNONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names Valid Anagram. Lowercase alphabet, empty-string behavior, bounds and callable interface are authored for practice; approximate source match 90%.

Return whether t can be formed by rearranging every character of s exactly once. Character multiplicities must match, and two empty strings are anagrams.

Function

isAnagram(s: String, t: String) → boolean

Examples

Example 1

s = "anagram"t = "nagaram"return = true

Each string contains three a letters, one n, one g, one r and one m.

Example 2

s = "rat"t = "car"return = false

The first string contains t; the second contains c instead.

Constraints

  • 0 <= s.length <= 2000.
  • 0 <= t.length <= 2000.
  • Both strings contain only lowercase English letters a through z.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public boolean isAnagram(String s, String t) {
    // Write your code here.
}
Checking account…