Check if The Number is Fascinating - Problem
You are given an integer n that consists of exactly 3 digits.
We call the number n fascinating if, after the following modification, the resulting number contains all the digits from 1 to 9 exactly once and does not contain any 0's:
Concatenate n with the numbers 2 * n and 3 * n.
Return true if n is fascinating, or false otherwise.
Note: Concatenating two numbers means joining them together. For example, the concatenation of 121 and 371 is 121371.
Input & Output
Example 1 — Fascinating Number
$
Input:
n = 192
›
Output:
true
💡 Note:
Concatenating 192 with 2×192=384 and 3×192=576 gives us 192384576. This contains all digits 1-9 exactly once with no zeros, making it fascinating.
Example 2 — Contains Zero
$
Input:
n = 100
›
Output:
false
💡 Note:
Concatenating 100 with 2×100=200 and 3×100=300 gives us 100200300. This contains zeros, which violates the fascinating number rule.
Example 3 — Duplicate Digits
$
Input:
n = 111
›
Output:
false
💡 Note:
Concatenating 111 with 2×111=222 and 3×111=333 gives us 111222333. This has duplicate digits (1 appears 3 times, 2 appears 3 times, 3 appears 3 times) instead of each digit 1-9 appearing exactly once.
Constraints
- 100 ≤ n ≤ 999
- n consists of exactly 3 digits
Visualization
Tap to expand
Understanding the Visualization
1
Input
3-digit number n = 192
2
Transform
Calculate 2×n=384, 3×n=576, concatenate: 192384576
3
Validate
Check if result contains digits 1-9 exactly once, no zeros
Key Takeaway
🎯 Key Insight: A fascinating number when tripled and concatenated creates a permutation of digits 1-9
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code