#C10351. First Unique Character
First Unique Character
First Unique Character
You are given a string s. Your task is to find the first character in s that occurs exactly once. If every character in s repeats or if the string is empty, you should output an empty string.
More formally, let s be a string of characters. Find the smallest index i such that the frequency of s[i] in s is 1. If no such index exists, output an empty string.
Examples:
- For
s = "swiss"
, the answer isw
. - For
s = "teeter"
, the answer isr
. - For
s = "aabb"
, the answer is an empty string.
Note: If there is no non-repeating character, print nothing.
inputFormat
The input consists of a single line containing the string s. The string may contain spaces and can be empty.
Input format:
<string s>
outputFormat
Print the first non-repeating character of the string. If no such character exists, output an empty string.
Output format:
<result character or empty>## sample
swiss
w