Self Dividing Numbers

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.
I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.
A self-dividing number is a number that is divisible by every digit it contains.
- For example,
128is a self-dividing number because128 % 1 == 0,128 % 2 == 0, and128 % 8 == 0.
A self-dividing number is not allowed to contain the digit zero.
Given two integers left and right, return a list of all the self-dividing numbers in the range [left, right] (both inclusive).
LeetCode Problem - 728
class Solution {
// Method to find all self-dividing numbers in the range [left, right]
public List<Integer> selfDividingNumbers(int left, int right) {
// List to store the self-dividing numbers
List<Integer> list = new ArrayList<>();
// Iterate through each number in the given range
for (int i = left; i <= right; i++) {
// Convert the current number to a string
String str = String.valueOf(i);
// Check if the number contains '0'; if it does, it cannot be self-dividing
if (!str.contains("0")) {
// Check if the number is self-dividing
if (selfDividingCheck(str)) {
// Add the self-dividing number to the list
list.add(i);
}
}
}
// Return the list of self-dividing numbers
return list;
}
// Helper method to check if a number represented as a string is self-dividing
public boolean selfDividingCheck(String str) {
// Convert the string representation of the number to an integer
int num = Integer.parseInt(str);
// Iterate through each character in the string representation
for (char ch : str.toCharArray()) {
// Convert the character to an integer
int tempNum = Integer.parseInt(String.valueOf(ch));
// If the digit is 0 or does not divide the number evenly, return false
if (tempNum == 0 || num % tempNum != 0) {
return false;
}
}
// If all digits divide the number evenly, return true
return true;
}
}




