← Amazon questions

Occurrence of a Character in a String

Filed under Amazon

Find the frequency of each character in a string. Initially, use a hash map, then discuss how to optimize or approach it using two pointers if the string is sorted.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.