#K81542. First Repeating Character
First Repeating Character
First Repeating Character
Given a string containing only lowercase English letters, your task is to find the first repeating character. In other words, determine the first character that appears at least twice in the string. If there is no repeating character, output None
.
The solution should consider the first repeating instance according to the order of characters from left to right. Use an efficient approach to handle the task.
In mathematical notation, if we denote the string as \(s = s_1s_2\ldots s_n\), find the smallest index \(i\) for which there exists an index \(j < i\) such that \(s_i = s_j\). If no such \(i\) exists, return \(None\).
inputFormat
The input consists of a single line containing a string \(s\) of lowercase English letters.
outputFormat
Output the first repeating character as described. If there is no repeating character, output None
.
abcba
b