← Quiz: Strings in C++: all 10 questions
Quiz: Strings in C++ · Question 10 of 10
Which is the simplest way to check whether two words are anagrams?
Which is the simplest way to check whether two words are anagrams?
- A.Compare their lengths only
- B.Compare the first and last letters
- C.Sort both strings and compare them
- D.Reverse one and compare
Answer & explanation
Correct answer: Sort both strings and compare them
Anagrams have the same letters with the same counts, so their sorted forms are equal.
Can you get the rest right without peeking?
Take the timed Quiz: Strings in C++ quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →