Valid Anagram

TopicDifficultyCompanies
Hash Table
MEDIUM
Google
Amazon
Microsoft

Given two strings "s1" and "s2", Write a program to check whether the two strings are an anagram of each other or not.

Problem Note

  • "s1" is an anagram of "s2" if the characters of "s1" can be rearranged to form "s2".
  • You may assume the string contains only lowercase alphabets.
  • If string s1 is an anagram of string s2return 1 as output, else 0.

Example 1

Input: s1 = “admirer” , s2 = “married”
Output: 1

Example 2

Input: s1 = “mindorks”, s2 = “mindrocks”
Output: 0

Code Editor

Practice and Learn

Best way to learn is through solving real problems. Practice this problem in this code editor.