leetcode:728. 自除数
2020-08-30 23:33
113 查看
自除数 是指可以被它包含的每一位数除尽的数。
例如,128 是一个自除数,因为 128 % 1 == 0,128 % 2 == 0,128 % 8 == 0。
还有,自除数不允许包含 0 。
给定上边界和下边界数字,输出一个列表,列表的元素是边界(含边界)内所有的自除数。
方法一:获取数组元素的每一位进行判断
class Solution { public List<Integer> selfDividingNumbers(int left, int right) { List<Integer> list = new LinkedList<>(); for(int i = left; i <= right; i++ ){ int j = i; while(j != 0 && (j % 10) != 0){ if(i % (j % 10) == 0) j = j / 10; else break; } if(j == 0) list.add(i); } return list; } }
相关文章推荐
- Leetcode刷题18-728.自除数(C++)
- LeetCode 728. 自除数 Python
- LeetCode 728. 自除数 python
- leetcode728.自除数
- leetcode 728. 自除数
- LeetCode-Python-728. 自除数
- Leetcode之动态规划(DP)专题-1025. 除数博弈(Divisor Game)
- 【LeetCode】1025.除数博弈
- LeetCode 728 自除数
- LeetCode 除数博弈
- leetcode刷题:除数博弈
- LeetCode 1025.除数博弈
- leetcode - 728 - 自除数
- LeetCode3-----除数博弈(分析法+动态规划,C语言实现)
- LeetCode_1025_除数博弈
- LeetCode 5024 除数博弈 (简单博弈论)
- 力扣(LeetCode)( 除数博弈)Python3
- leetcode(728) 自除数
- leetcode - 除数博弈
- leetcode1025除数博弈python实现