Question DSA-STR-0048
MediumHow can you check whether two strings of length n are anagrams in O(n) time?
- A.
Sort both and compare (O(n) always)
- B.
Compare them character by character
- C.
Reverse one and compare
- D.
Count the characters of each with an array or hash map and compare the counts
Sign up free to see the answer and a step-by-step explanation.