Skip to content

How do you find out if the given two strings are anagrams or not? I'm having a lot of trouble with this. #1664

Answered by Emojees
Kuefo asked this question in Q&A
Discussion options

You must be logged in to vote

Two strings are anagrams if they contain similar characters in a varied sequence. Declare a boolean variable that tells at the end of the two strings are anagrams or not.
First, check if the length of both strings is the same, if not, they cannot be anagrams.
Convert both the strings to character arrays and then sort them.
Check if the sorted arrays are equal. If they are equal, print anagrams, otherwise not anagrams.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Kuefo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants