We use unordered_map for hashing. Firstly we just iterate through string and we save in our map how many times we saw each char. Then we iterate again through a string and we if find some char which value in map is 1, we return that char. If we didnt find any we return -1. Time complexity is O(|S|), where S is our string on input.
We use unordered_map for hashing. Firstly we just iterate through string and we save in our map how many times we saw each char. Then we iterate again through a string and we if find some char which value in map is 1, we return that char. If we didnt find any we return -1. Time complexity is O(|S|), where S is our string on input.