Google Online Assessment (OA) 2021 | Smallest Integer Satisfying the Rule
You have a number written down on a piece of paper. Unfortunately, you are extremely clumsy and you knocked over a bottle of ink, which covered the paper. This causes some numbers to be completely illegible.
This number is very important to you, so you want to reconstruct the number. You don't remember the original number, but you distinctly remember that this number has two peculiar attributes: it has no zeros anywhere in the number, and each adjacent digits are distinct. With this information, it is not necessarily possible to guarantee a number, so you just want to find the lowest possible number given the current information.
digits: A string of length
1 ~ 9and/or
?(which represents an illegible digit).
- A string representing the lowest possible number that satisfy the conditions described above.
digits = "1??13"
digits = "?1???2??3???4?"
1 <= n <= 2000