#C5273. First Non-Repeating Character

    ID: 48904 Type: Default 1000ms 256MiB

First Non-Repeating Character

First Non-Repeating Character

Given a string s, your task is to find the first non-repeating character in the string and print it. A non-repeating character is a character that appears exactly once in the string. If there is no such character, output an underscore (_).

For example:

  • For s = "leetcode", the answer is l because 'l' is the first character that does not repeat.
  • For s = "aabb", all characters repeat so the answer is _.

The problem can be formally described using the formula: \[ ans = \begin{cases} \text{first } c \in s \text{ such that } f(c)=1, & \text{if exists}\\ _, & \text{otherwise} \end{cases} \] where \( f(c) \) denotes the frequency of character \( c \) in string \( s \).

inputFormat

The input consists of a single line which is a string s. The string will be read from stdin. It may contain spaces and other printable characters.

outputFormat

Output a single character which is the first non-repeating character in the string. If there is no such character, output an underscore (_). The result should be printed to stdout.

## sample
leetcode
l