Microsoft interview question

Return first non repeating character in a string and then optimize it.