Question DSA-STR-0033
EasyHow can you check in O(n) time whether two strings are anagrams?
- A.
Check whether they have the same first letter
- B.
Compare every pair of characters
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Strings question
How can you check in O(n) time whether two strings are anagrams?
Check whether they have the same first letter
Compare every pair of characters
Sign up free to see the answer and a step-by-step explanation.
Count how often each character appears in both and compare the counts
Reverse one string and compare