Thursday, 19 September 2013

Find the first non repetitive character in a string

Find the first non repetitive character in a string

I was asked this question in an interview. My answer: "create an array of
size 26. Traverse the string by each character and make counts of
characters in the array. Check the first non repetitive character by
traversing again in the string and checking the array if the character is
not repeated." What if the string contains large set of characters like
10000 types of characters instead of 26 types of alphabets.

No comments:

Post a Comment