100 Days of Code: Fascinating Number Checker

🚀 #100DaysOfCode – Day 15 | DSA Practice Continuing my 100 Days Data Structures and Algorithms challenge, today I solved an interesting problem based on numbers and digit manipulation. 📌 Problem: Check if The Number is Fascinating Given a 3-digit number n, we need to check whether it is fascinating or not. A number is called fascinating if: 👉 Concatenate n, 2*n, and 3*n 👉 The resulting number contains all digits from 1 to 9 exactly once 👉 It should not contain 0 Example: Input: n = 192 Concatenation → 192384576 Output → true 🧠 Approach / Logic: 1️⃣ Convert the numbers n, 2*n, and 3*n into strings and concatenate them. 2️⃣ Check if the total length of the string is 9. 3️⃣ Traverse the string and count the frequency of each digit. 4️⃣ If any digit is 0, return false. 5️⃣ Ensure each digit from 1 to 9 appears exactly once. 6️⃣ If all conditions are satisfied, the number is fascinating. 📊 Time Complexity: O(1) 📦 Space Complexity: O(1) 🎯 Key Learning: This problem highlights how string manipulation and frequency counting can be used to validate patterns in numbers. Consistency is the key to growth. Let’s keep improving every day! 💪 #100DaysOfCode #DSA #CodingJourney #ProblemSolving #CPP #LearningInPublic

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories