Find the first non-repeating character in a string
Sigiloso
The straightforward answer is to loop over the string, and for each character check the whole string if it is repeated. This solution is O(n^2). Better would be to remember each character visited and keep a count of how often it was encountered. You would initially have a 0 count for every character in the alphabet, or an empty hash map with the same purpose. Then go over the whole string and increment the counter for each character you encounter. Finally, go over the string and look up for each character how often it was encountered. The first one with a count of 1 is the one you are looking for. This algorithm requires the list to be searched twice, and is O(n).