当前位置:网站首页>Leetcode simple problem: converting an integer to the sum of two zero free integers
Leetcode simple problem: converting an integer to the sum of two zero free integers
2022-06-12 05:45:00 【Python's path to becoming a God】
subject
「 Zero free integer 」 Is in the decimal representation It doesn't contain any 0 The positive integer .
Give you an integer n, Please return one A list of two integers [A, B], Satisfy :
A and B Are zero free integers
A + B = n
The problem data ensures that there is at least one effective solution .
If there are multiple effective solutions , You can return any of them .
Example 1:
Input :n = 2
Output :[1,1]
explain :A = 1, B = 1. A + B = n also A and B The decimal representation of does not contain any 0 .
Example 2:
Input :n = 11
Output :[2,9]
Example 3:
Input :n = 10000
Output :[1,9999]
Example 4:
Input :n = 69
Output :[1,68]
Example 5:
Input :n = 1010
Output :[11,999]
Tips :
2 <= n <= 10^4
source : Power button (LeetCode)
Their thinking
First, define a function that decomposes each bit , Then loop through various situations , Return the qualified conditions .
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
def find(n):
while n>0:
if not n%10:
return False
n//=10
return True
for i in range(1,n):
if find(i) and find(n-i):
return [i,n-i]

边栏推荐
- Nature | make an account of the new crown casualties in the world
- 数据库实验三:数据查询
- 按键精灵的简单入门
- 个人申请OV类型SSL证书
- Halcon 用点来拟合平面
- Necessary for Test Engineer -- package capturing tool fiddler
- SIM卡信号的驱动电流是多少mA,是否是可调节的?
- 第五讲:数据仓库搭建(三)
- RTMP streaming +rtmp playback low delay solution in unity environment
- How long is the company's registered capital subscribed
猜你喜欢

16. 最接近的三數之和

登录验证过滤器

Available RTMP and RTSP test addresses of the public network (updated in March, 2021)

数据集成框架SeaTunnel学习笔记

Introduction to Internet Protocol

Matlab: image rotation and interpolation and comparison of MSE before and after

beginning一款非常优秀的emlog主题v3.1,支持Emlog Pro
![【长时间序列预测】Aotoformer 代码详解之[4]自相关机制](/img/12/27531fc791b3f49306385831309c5e.png)
【长时间序列预测】Aotoformer 代码详解之[4]自相关机制

BlockingQueue interface introduction

Towards End-to-End Lane Detection: an Instance SegmentationApproach
随机推荐
GRP development: four communication modes of GRP
March 22, 2021
个人申请OV类型SSL证书
[road of system analyst] collection of wrong topics in software engineering chapters
Matlab: image rotation and interpolation and comparison of MSE before and after
Lock and reentrankload
Introduction to Internet Protocol
公司注册认缴资金多久
Introduction to redis cluster
[speech] how to customize ring back tone according to different countries
Go interface implementation principle [advanced level]
Selenium crawler automatically captures TOEFL test position of NEEA website
Automated test - dark horse headline test project
Simple introduction to key Wizard
[gpio] how to modify / display GPIO status through ADB shell
[JS knowledge] easily understand JS anti shake and throttling
beginning一款非常优秀的emlog主题v3.1,支持Emlog Pro
Select gb28181, RTSP or RTMP for data push?
yolov5
[untitled]