Given a string, this function finds the first non-repeating character in it.
The candidate's solution correctly finds the first non-repeating character in a string. The solution uses a hash map to keep track of the number of times each character appears in the string, then loops through the string again to find the first character with a count of 1. One potential improvement to this solution would be to use a LinkedHashMap instead of a regular hash map, so that the order in which the characters are added to the map is preserved. This would allow the solution to find the first non-repeating character in the string in a single loop, without having to loop through the string twice.
Evaluated at: 2022-12-10 12:15:23