Back to problems

Build Smallest Number

Algorithm · Airbnb · Hard

You are given an array of single-digit integers digits. Drop every 0, then use each remaining digit exactly once to construct the smallest possible non-negative integer by joining them together in any sequence. The answer should be returned as a string. It must not have leading zeros, unless the number itself is "0". Every non-zero digit must be used exactly once, and zeros are never placed in the result. If digits contains nothing but zeros, return "-1". Example 1:…

Checking your access…