Implement the firstNonRepeatingCharacter method that returns the first character in the text that appears only once.

The input contains a string text. Your task is to return the first character that appears only once in the string.

If every character is repeated, return #. For example, in aabbcde, the first non-repeating character is c.

Example 1
Input:
text (string) = aabbcde
Return:
(char) c
Example 2
Input:
text (string) = aabb
Return:
(char) #
Example 3
Input:
text (string) = swiss
Return:
(char) w

First count how many times each character appears in the string.

Then scan the string again from left to right. The first character with frequency 1 is the answer. If no such character exists, return #.

Pseudocode:

function firstNonRepeatingCharacter(text):
    frequency = empty map
    for each character in text:
        frequency[character]++
    for each character in text:
        if frequency[character] == 1:
            return character
    return '#'
Run your code to see the result.