Viasat Interview Question

How would you find the first non-repeating character in a string?

Interview Answer

Anonymous

Mar 30, 2013

Map the frequencies of each character possible onto an array of length 256 (0-255 are values for characters on the ASCII chart), while also keeping track of the priorities (aka how far away from the start of the string are they). That way all you have to do is go through the array, look only at frequencies of one, then check the priority and keep track of the index.

1