self-dividing number is a number that is divisible by every digit it contains.

For example, 128 is a self-dividing number because 128 % 1 == 0128 % 2 == 0, and 128 % 8 == 0.

Also, a self-dividing number is not allowed to contain the digit zero.

Given a lower and upper number bound, output a list of every possible self dividing number, including the bounds if possible.

Example 1:

Input:
left = 1, right = 22
Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]

Note:

  • The boundaries of each input argument are 1 <= left <= right <= 10000.

Brute-Force!!!

class Solution:
def selfDividingNumbers(self, left, right):
"""
:type left: int
:type right: int
:rtype: List[int]
"""
result=[] for num in range(left, right+1):
strnum=str(num) flag=True for digit in strnum:
if digit=='0':
flag=False
break if num%int(digit) !=0:
flag=False
break if flag:
result.append(num) return result

  

最新文章

  1. 基于类的命令行notebook的实现
  2. 疯狂房价&quot;逼死&quot;年轻人,别指望中国未来能出人才了
  3. 有关struts2中用到 js 总结
  4. jQuery带遮罩层弹窗实现(附源码)
  5. 让你的 Node.js 应用跑得更快的 10 个技巧(转)
  6. 各种好用的工具之一 ---- PNGGauntlet
  7. Android 主题动态切换框架:Prism
  8. B - Network - uva 315(求割点)
  9. 去除html页面中按钮在ios中的默认样式,去除select自带的小三角图标
  10. [Android阅读代码]android-async-http源码学习一
  11. !important的理解
  12. 深入学习Java8 Lambda (default method, lambda, function reference, java.util.function 包)
  13. Java消息队列——JMS概述
  14. Zookeeper安装及运行
  15. Notepad++ 中使用tail -f功能
  16. HTML 样式兼容不同设备类型
  17. hibernate Validator 6.X 的学习,bean的约束(主要包括的是容器元素的验证)
  18. document.visibilityState 监听浏览器最小化
  19. CF 166E Tetrahedron
  20. Android开发高级进阶——多进程间通信

热门文章

  1. CKEditor5 基本使用
  2. 【Golang 接口自动化05】使用yml管理自动化用例
  3. Java 常用对象-Math类
  4. Python 爬虫-BeautifulSoup
  5. js中如何访问对象和数组
  6. 『Python』pycharm常用设置
  7. mysql导入导出数据过大命令
  8. Oracle11g温习-第四章:手工建库
  9. 62. 63. Unique Paths 64. Minimum Path Sum
  10. js获得焦点和失去焦点那些事