Skip to content

Practice Find Valid Pair of Adjacent Digits in String

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

Easy#3438
LeetCode Problem

Find Valid Pair of Adjacent Digits in String

Problem Statement

Given the digit string s, find the first pair of adjacent different digits, scanning left to right, such that each digit occurs in the whole string exactly as many times as its numeric value. Return that two-character pair, or an empty string if none exists.

Source: Find Valid Pair of Adjacent Digits in String on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "2523533"
Output
"23"

# Example 2

Input
s = "221"
Output
"21"

# Example 3

Input
s = "22"
Output
""

Constraints

2 <= s.length <= 100
s only consists of digits from '1' to '9'.

Related LeetCode Problems

Practice more problems similar to Find Valid Pair of Adjacent Digits in String.

Review your practice with PhantomCodeAI

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