Interview Question
Software Engineer / Developersneed understand the difference between array and hashtable .
your solution is actually an array of 26 element , you don't have to use hash function since what you want to do is to map your character to index.
Create a Hashtable. Its key should be the character encountered in the string.
- Anonymous June 29, 2010Now start traversing the string. For each character, if its entry exists in the hashtable, increment its count. Else create a new entry for this character in hashtable with its count set to 1.