FastPrepCheck Anagrams
Problems/Check Anagrams

Check Anagrams

Deloitte logoDeloitte● EasyFULLTIMENEW GRADONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

You are given two strings s and t.

Determine whether the two strings are anagrams of each other. Two strings are anagrams if they contain exactly the same characters with the same frequencies, possibly in a different order.

Return 1 if the strings are anagrams, otherwise return 0.

Function

checkAnagrams(s: String, t: String) → int

Examples

Example 1

s = "listen"t = "silent"return = 1

listen and silent contain the same letters with the same frequencies.

Example 2

s = "race"t = "care"return = 1

race and care are anagrams.

Example 3

s = "hello"t = "world"return = 0

The two strings do not have matching character frequencies.

Constraints

  • s and t consist of printable characters.
  • The comparison is case-sensitive.

More Deloitte problems

  • Second-Highest Distinct SalaryPHONE SCREEN · Seen Jul 2026
  • Seventh Nearest PalindromeOA · Seen May 2026
  • Minimum Deletions for a Non-PalindromeOA · Seen Jul 2025
All Deloitte interview questionsSee Deloitte hiring insights
Saved
class Solution {
    public int checkAnagrams(String s, String t) {
      // write your code here
    }
}
Checking account…