Skip to content

Practice First Letter to Appear Twice

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2351
LeetCode Problem

First Letter to Appear Twice

Problem Statement

Scan s from left to right and return the letter whose second occurrence is encountered first. At least one lowercase letter is guaranteed to repeat.

Source: First Letter to Appear Twice on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "abccbaacz"
Output
"c"

# Example 2

Input
s = "abcdd"
Output
"d"

Constraints

2 <= s.length <= 100
s consists of lowercase English letters.
s has at least one repeated letter.

Related LeetCode Problems

Practice more problems similar to First Letter to Appear Twice.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.