FastPrepCase-Insensitive Anagram Check

Case-Insensitive Anagram Check

Upstart logoUpstart● EasyFULLTIMEOA
Learn

Problem statement

Given two strings wordA and wordB, return true when they are anagrams of each other and false otherwise.

The comparison is case-insensitive. Anagrams must contain the same letters with the same multiplicities, but the letters may appear in any order.

Function

isAnagram(wordA: String, wordB: String) → boolean

Examples

Example 1

wordA = "Drier"wordB = "Rider"return = true

After ignoring case, both words contain one d, one e, one i, and two r letters.

Example 2

wordA = "hello"wordB = "world"return = false

The two words have different letter counts, so they are not anagrams.

Constraints

  • wordA and wordB are defined and may be empty.
  • Each string contains only uppercase and lowercase English letters.
  • 0 ≤ wordA.length, wordB.length ≤ 30.

More Upstart problems

See Upstart hiring insights
public boolean isAnagram(String wordA, String wordB) {
    // write your code here
}
wordA"Drier"
wordB"Rider"
expectedtrue
Checking account…