Construct smallest number from I/D pattern | Airbnb Interview Question