当前位置:网站首页>Leetcode+ 66 - 70 high precision, two sub topics
Leetcode+ 66 - 70 high precision, two sub topics
2022-06-28 07:02:00 【Sauerkraut】
Add one
Algorithm tags : Array 、 mathematics

Give us an integer , This integer is represented by an array , Add... To this integer 1, Add 1 After that, we use array to represent , The highest bit of the array is placed at 0 A place , Put the second highest order to the 1 A place , Suppose this array has no leading 0, In fact, it gives a very long integer , Simulate the process of addition

Because the highest bit may carry , So you need to flip the array first , Keep your position at the 0 A place , Ten in the first place 1 A place , Start with a bit , Calculate the value of the current bit each time , See if there is a carry , If there is a carry, carry one
How to calculate the number in the current position each time ?
A bit should be the number in the original position plus 1, Plus the carry , add 1 It can be seen as a step forward , Each digit can be regarded as the original digit plus the carry , The carry can be 0 It can also be 1, After adding , The number of current positions is the sum of this number divided by 10 The remainder of , The carry is the sum and division of this number
边栏推荐
猜你喜欢

Recommend 10 popular jupyter notebook plug-ins to make you fly efficiently

声网 VQA:将实时互动中未知的视频画质用户主观体验变可知

fpm工具安装
面经---测试工程师web端自动化---大厂面试题

什么是一致性哈希?可以应用在哪些场景?

「杰伦熊」暴跌96.6% 明星带货NFT为何遇冷?

How bacnet/ip gateway collects data of building centralized control system
![[c #] [reprint]furion frame address and tutorial address](/img/b2/e1c30153c4237188b60e9523b0a5d8.png)
[c #] [reprint]furion frame address and tutorial address

Recommend several 0 code, free, learning and using visualization tools

助力涨点 | YOLOv5结合Alpha-IoU
随机推荐
【Rust翻译】从头实现Rust异步执行器
4. use MySQL shell to install and deploy Mgr clusters | explain Mgr in simple terms
Rust FFI 编程 - libc crate
[rust daily] May 24, 2020 rush, rocket, Mun, caspin
Wechat applet paging function, pull-down refresh function, direct dry goods
FPGA - 7 Series FPGA selectio -07- iserdese2 of advanced logic resources
【网络教程】IPtables官方教程--学习笔记1
Some habits of it veterans in the workplace
代码没写错,渲染页面不显示原因
NDK 交叉编译
Techo day Tencent technology open day, June 28 online waiting for you!
[produced by Xinghai] operation and maintenance inspection collection
[interval DP] stone consolidation
Iphone6plus enters the list of antique products netizen: I'm still using it
Interpretation of Blog
最后的二十九天
Niubi 666, this project makes web page making as simple as building blocks
编译原理期末复习
C语言教程大全
三极管驱动无刷电机