当前位置:网站首页>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
边栏推荐
- Freeswitch sets the maximum call duration
- ice - 资源
- AttributeError: 'callable_ iterator' object has no attribute 'next'
- JS of learning notes -- split(), replace(), join()
- Iphone6plus enters the list of antique products netizen: I'm still using it
- Recommend several 0 code, free, learning and using visualization tools
- 炒股开户在手机上安全吗?
- 面经---测试工程师web端自动化---大厂面试题
- 普歌 -- getOrDefault()方法理解
- Extern "C" overview
猜你喜欢

Freeswitch uses Mod_ Shot module plays mp3

LeetCode+ 66 - 70 高精度、二分专题

FPGA - 7 Series FPGA selectio -07- iserdese2 of advanced logic resources

小小一款代码编辑器竟然也可以有程序运行之功能——Sublime Text3运行各种语言程序的总结

Design and practice of vivo sensitive word matching system

Wechat applets - basics takes you to understand the life cycle of applets (I)

Niubi 666, this project makes web page making as simple as building blocks

CRC32概述以及实现和使用

Techo Day 腾讯技术开放日,6月28日线上等你!

What is a consistent hash? What scenarios can it be applied to?
随机推荐
Freeswitch uses origin to dialplan
饿久了,大脑会进入“省电模式”!感官被削弱,还看不清东西丨爱丁堡大学...
ice, protobuf ,thrift -- 笔记
Optimization steps of SQL statements (II) -- MySQL statement optimization
Techo day Tencent technology open day, June 28 online waiting for you!
Students who do not understand the code can also send their own token. The current universal dividend model can be divided into BSC and any generation B
Tryout title code
Design and practice of vivo sensitive word matching system
Puge -- understanding of getordefault() method
微信小程序编译页面空白bug的原因
[rust translation] implement rust asynchronous actuator from scratch
This keyword details
小程序页面设置100%高度还是留白怎么办?
普歌--三大基础排序,冒泡·选择·快速
Pfizer's new Guankou medicine has entered the Chinese market, and the listing of relevant products of domestic pharmaceutical enterprises is just around the corner
助力涨点 | YOLOv5结合Alpha-IoU
最后的二十九天
What if the applet page is set to 100% height or left blank?
What is a consistent hash? What scenarios can it be applied to?
[interval DP] stone consolidation