Based on this question from Code Review
Given a non-empty string of printable ASCII characters, output the second non-repeating character. For example, for input DEFD
, output F
.
Input
- A single string, in any suitable format.
Output
- The second character that doesn't repeat, when reading left-to-right, again in a suitable format.
- The output character is case-insensitive.
- If no such character exists (e.g., all characters repeat), output an empty string.
Rules
- The algorithm should ignore case. That is,
D
andd
count as the same character. - Either a full program or a function are acceptable.
- The input string will be guaranteed non-empty (i.e., at least one character in length).
- The input string is ASCII. Any valid character could repeat, not just alphanumeric (this includes spaces).
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
Examples
Input is on first line, output is on second line.
DEFD
F
FEED
D
This is an example input sentence.
x
...,,,..,,!@
@
ABCDefgHijklMNOPqrsTuVWxyz
B
AAAAAABBBBB
Thisxthis
This this.
.