Blog on algorithms, puzzles, programming .... musings of a computer engineer.
Find first non-duplicate character in a string
Find first non-duplicate character in a string.
Solution:
lookup['z'-'a'] = {0} Pass 1: Traverse the string, and perform ++lookup[string[i]]; Pass 2: Traverse the string, and the first char for which lookup[string[i]] == 1 is the required char.
No comments:
Post a Comment