Given a string s consisting of lowercase English letters, return the first character that appears twice.
A character is considered the first to appear twice if the index of its second occurrence is strictly smaller than the index of the second occurrence of any other character.
Note:
sis guaranteed to contain at least one character that appears multiple times.
Constraints:
s.length
s consists of lowercase English letters.
s contains at least one repeated letter.
Given a string s consisting of lowercase English letters, return the first character that appears twice.
A character is considered the first to appear twice if the index of its second occurrence is strictly smaller than the index of the second occurrence of any other character.
Note:
sis guaranteed to contain at least one character that appears multiple times.
Constraints:
s.length
s consists of lowercase English letters.
s contains at least one repeated letter.