#2729

Check if The Number is Fascinating

pupil · 430 · lc easy +25 · premium · verified · 52.9% accepted · 263 likes · top 43%

Description

An exactly 3-digit integer n is fascinating if concatenating n, 2 * n, and 3 * n as strings produces a 9-character sequence containing each digit 19 exactly once with no zeros. Return true if n is fascinating, false otherwise.

Example 1:

Input: n = 192
Output: true
Explanation: We concatenate the numbers n = 192 and 2 * n = 384 and 3 * n = 576. The resulting number is 192384576. This number contains all the digits from 1 to 9 exactly once.

Example 2:

Input: n = 100
Output: false
Explanation: We concatenate the numbers n = 100 and 2 * n = 200 and 3 * n = 300. The resulting number is 100200300. This number does not satisfy any of the conditions.

Code

1
2
3