- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check whether two strings are anagram of each other in Python
Suppose we have two strings s and t we have to check whether they are anagram of each other or not.
So, if the input is like s = "bite" t = "biet", then the output will be True as s ad t are made of same characters.
To solve this, we will follow these steps −
- if size of s is not same as size of t, then
- return False
- sort characters of s and t
- return true if s is exactly same as t, otherwise false
Let us see the following implementation to get better understanding −
def solve(s, t): if len(s) != len(t): return False s = sorted(s) t = sorted(t) return s == t s = "bite" t = "biet" print(solve(s, t))
- Check if two strings are anagram of each other using C++
- Java Program to check whether two Strings are an anagram or not.
- Java Program to Check if two strings are anagram
- Golang Program to Check if two Strings are Anagram
- Check if strings are rotations of each other or not in Python
- Program to check strings are rotation of each other or not in Python
- How to check if two Strings are anagrams of each other using C#?
- Program to partition two strings such that each partition forms anagram in Python
- Check if binary representations of two numbers are anagram in Python
- Program to check whether final string can be formed using other two strings or not in Python
- Check whether two strings are equivalent or not according to given condition in Python
- Python program to check if binary representation of two numbers are anagram.
- A Program to check if strings are rotations of each other or not?
- Python - Check if two strings are isomorphic in nature