"Self Dividing Numbers LeetCode Solution in Java"

🔹 Day 52: Self Dividing Numbers (LeetCode #728) 📌 Problem Statement: A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is self-dividing because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. Given two integers left and right, return a list of all self-dividing numbers in that range (inclusive). ✅ My Approach: I iterated through each number in the range [left, right] and checked if it was self-dividing using a helper function. For each number: Extract each digit using modulo and division. If any digit is zero or the number isn’t divisible by that digit, it’s not self-dividing. Otherwise, include it in the result list. 📊 Complexity: Time Complexity: O(n × d), where d is the number of digits. Space Complexity: O(1) (excluding the output list). ⚡ Submission Stats: Runtime: 2 ms (Beats 73.19%) Memory: 42.48 MB (Beats 10.09%) 💡 Reflection: This problem strengthened my skills in digit manipulation and modular arithmetic. It’s a great exercise for mastering number decomposition and iteration logic. ✨ #LeetCode #Java #Math #Loops #100DaysOfCode #Day52

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories