digits made of the digits 1 through 9. Two **adjacent** digits form a matching pair when:
- the two digits are different;
- each of them occurs in the whole string exactly as many times as its own value (for example, 3 occurs exactly three times).
Scanning from left to right, find the first matching pair and return it as a two-character string. If there is no such pair, return an empty string.digits='4134344' → '41'
The pair "41": 4 occurs four times, 1 occurs once, and the digits differ. It is the leftmost such pair.
digits='3313' → '31'
3 occurs three times and 1 once. "33" does not count since the digits are equal, so the first fit is "31".
digits='5512' → ''
1 occurs once, but its neighbors fail: 5 occurs twice and 2 only once. No pair qualifies, so the answer is an empty string.
digits.length ≤ 100digits consists only of the digits 1 to 9digits='4134344'
'41'
Run checks the first 3 tests in your browser. Submit checks all 167 tests on the server, hidden ones included.