#K59682. First Non-Repeating Character
First Non-Repeating Character
First Non-Repeating Character
You are given a string consisting of lowercase alphabets and spaces. Your task is to find the first character that does not repeat in the string, ignoring any spaces. If every character (ignoring spaces) repeats, then output a single space.
For example, given the input string "this is a test string", the first non-repeating character is h
because even though other characters appear, it is the first unique one when spaces are not considered.
The solution should correctly handle edge cases such as a string with only one character, a string where every character repeats, or strings containing extra spaces at the beginning or in between.
inputFormat
Input is read from standard input (stdin) as a single line containing the string.
outputFormat
Output the first non-repeating character to standard output (stdout). If no such character exists, output a single space.## sample
this is a test string
h