155. Check if Two Strings are Anagrams

EasyStringString

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

An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once.

The comparison is case-insensitive.

Input: Two comma-separated strings: s and t.

Output: Return 'true' if t is an anagram of s, otherwise 'false'.

Examples

Example 1
Input: listen,silent
Output: true
Explanation: Both words contain the same letters: e, i, l, n, s, t → anagram.
Example 2
Input: hello,world
Output: false
Explanation: The character counts differ significantly → not anagram.
Example 3
Input: anagram,nagaram
Output: true
Explanation: Both use a×3, n×1, g×1, r×1, m×1 → anagram.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →