Given two strings s1 and s2, check if both the strings are anagrams of each other.
Input : s1 = "listen" s2 = "silent" Output : The strings are anagrams. Input : s1 = "dad" s2 = "bad" Output : The strings aren't anagrams.
Python provides a inbuilt function sorted() which does not modify the original string, but returns sorted string.
Below is the Python implementation of the above approach:
The strings are anagrams.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check whether two strings are anagram of each other
- Check whether two Strings are Anagram of each other using HashMap in Java
- Using Counter() in Python to find minimum character removal to make two strings anagram
- Remove minimum number of characters so that two strings become anagram
- Minimum Number of Manipulations required to make two Strings Anagram Without Deletion of Character
- Python Dictionary | Check if binary representations of two numbers are anagram
- Check if any anagram of a string is palindrome or not
- Check if binary representations of two numbers are anagram
- Longest common anagram subsequence from N strings
- Number of sub-strings which are anagram of any sub-string of another string
- Check if binary representation of a given number and its complement are anagram
- Search in an array of strings where non-empty strings are sorted
- Meta Strings (Check if two strings can become same after a swap in one string)
- Check whether two strings can be made equal by reversing substring of equal length from both strings
- Program to check if two strings are same or not
- Check whether two strings are equivalent or not according to given condition
- Check if two strings after processing backspace character are equal or not
- Check if two strings are k-anagrams or not
- Python | Check if list is sorted or not
- Anagram checking in Python using collections.Counter()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.