Leetcode Problem 2729. Check if The Number is Fascinating

2729. Check if The Number is Fascinating

Leetcode Solutions

Checking for Unique Digits and Concatenation

  1. Convert the number n and its multiples 2 * n and 3 * n to strings and concatenate them.
  2. Check if the concatenated string contains the digit 0. If it does, return false.
  3. Check if the length of the concatenated string is exactly 9. If not, return false.
  4. Convert the concatenated string to a set to remove any duplicate digits.
  5. Check if the length of the set is exactly 9, which would mean all digits from 1 to 9 are present exactly once.
  6. If all checks pass, return true. Otherwise, return false.
UML Thumbnail

Digit Frequency Counting

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...