First Non-Repeated Character
Problem statement
Given a string s, return the first character whose total frequency in the complete string is exactly one.
Character comparison is case-sensitive. Return the empty string when no character occurs exactly once.
Function
firstNonRepeatedCharacter(s: String) → StringExamples
Example 1
s = "swiss"return = "w"The first s repeats, while w appears once and is encountered before i.
Example 2
s = "aabbcc"return = ""Every character repeats, so there is no qualifying result.
Constraints
0 <= s.length <= 10^5.- Every character is printable ASCII.