Find the first adjacent pair of digits in a string that satisfies a validity rule based on digit frequencies.
Given a string consisting only of digits, examine each pair of adjacent characters from left to right and return the first pair that is considered valid according to the problem's rule. If no adjacent pair satisfies the condition, return an empty result or a sentinel value as specified by the platform version.
A typical validity rule for this kind of problem is that the two digits must be different and each digit must appear in the string exactly as many times as its numeric value. The goal is to identify the earliest adjacent pair that meets the rule after counting digit frequencies across the whole string.
s containing only numeric characters.Interpret the exact validity rule using the platform statement; the most likely rule is based on global digit frequencies and adjacent characters.
2 <= s.lengths contains only characters '0' to '9'Example 1
Input
s = "1210"
Output
"21"
Explanation
Digit frequencies are: 1 -> 2 times, 2 -> 1 time, 0 -> 1 time. The adjacent pair "12" is not valid, but "21" is the first pair where each digit appears in the string exactly as many times as its value.
Example 2
Input
s = "123"
Output
""
Explanation
No adjacent pair satisfies the validity rule.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.