Tap here to switch tabs
Problem
Submissions

Problem: Find Valid Pair of Adjacent Digits in String

Find Valid Pair of Adjacent Digits in String asks you to return the first neighboring pair with different digits, where each digit appears as many times as its value, or an empty string if none exists.

Statement

You are given a string s consisting of digits from ′1′'1' to ′9′'9'.

A pair of adjacent characters in s is considered valid if:

  • The two adjacent characters are not equal.

  • The total count of each character in s is equal to its numeric value.

Return the first valid pair of adjacent characters encountered from left to right. If no valid pair exists, return an empty string "".

Constraints:

  • 2≤2 \leq s.length ≤100\leq 100

  • s consists only of digits from ′1′'1' to ′9′'9'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Valid Pair of Adjacent Digits in String

Find Valid Pair of Adjacent Digits in String asks you to return the first neighboring pair with different digits, where each digit appears as many times as its value, or an empty string if none exists.

Statement

You are given a string s consisting of digits from ′1′'1' to ′9′'9'.

A pair of adjacent characters in s is considered valid if:

  • The two adjacent characters are not equal.

  • The total count of each character in s is equal to its numeric value.

Return the first valid pair of adjacent characters encountered from left to right. If no valid pair exists, return an empty string "".

Constraints:

  • 2≤2 \leq s.length ≤100\leq 100

  • s consists only of digits from ′1′'1' to ′9′'9'.