#3438

Find Valid Pair of Adjacent Digits in String

pupil · 385 · lc easy +24 · 60.6% accepted · 78 likes · top 59%

Description

You are given a string s consisting only of digits. A valid pair is two adjacent digits satisfying:

- The two digits are different from each other.

- Each digit in the pair appears in s exactly as many times as its numeric value.

Return the first valid pair found while scanning s from left to right, or an empty string if none exists.

Code

1
2
3