FastPrepValid Anagram

Valid Anagram

Motive logoMotive● EasyFULLTIMEONSITE INTERVIEW
Learn

Problem statement

Given two lowercase English strings s and t, return true if t is an anagram of s, and false otherwise.

Function

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

Examples

Example 1

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

Example 2

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

Constraints

  • 0 <= s.length, t.length <= 100000.
  • Both strings contain lowercase English letters only.

More Motive problems

See Motive hiring insights
public boolean isAnagram(String s, String t) {
  // write your code here
}
s"anagram"
t"nagaram"
expectedtrue
Checking account…