A monitoring script scans a raw log token — a single string made only of lowercase English letters — looking for the first character that was logged exactly once.
Given the token, find the leftmost character that appears exactly once in it. Print that character. If every character repeats (no character appears exactly once), print NONE.
Line 1: a string s consisting only of lowercase English letters (a-z).
A single line containing the first (leftmost) character of s that occurs exactly once in s, or the literal text NONE if no such character exists.
s contains only lowercase English letters.Example 1
Input
swiss
Expected
w
Explanation
's' occurs 3 times and 'w' occurs once. Scanning left to right, 'w' is the first character with count 1, so it is printed.
Example 2
Input
aabbcc
Expected
NONE
Explanation
Every character occurs exactly twice, so there is no character with count 1; the output is NONE.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →