当前位置:网站首页>20220607其他:两整数之和
20220607其他:两整数之和
2022-07-03 09:20:00 【丿SeeYouAgain】
题目描述:给你两个整数 a
和 b
,不使用 运算符 +
和 -
,计算并返回两整数之和。
编码实现:
public static int getSum(int a, int b) {
int bit = (a & b) << 1;
int result = a ^ b;
if (bit != 0){
return getSum(result,bit);
}
return result;
}
边栏推荐
- Leetcode - 1670 design front, middle and rear queues (Design - two double ended queues)
- 1. Finite Markov Decision Process
- Opencv image rotation
- 3.2 Off-Policy Monte Carlo Methods & case study: Blackjack of off-Policy Evaluation
- QT self drawing button with bubbles
- LeetCode - 460 LFU 缓存(设计 - 哈希表+双向链表 哈希表+平衡二叉树(TreeSet))*
- Vgg16 migration learning source code
- Serial port programming
- LeetCode - 703 数据流中的第 K 大元素(设计 - 优先队列)
- Crash工具基本使用及实战分享
猜你喜欢
CV learning notes ransca & image similarity comparison hash
Installation and removal of MySQL under Windows
Opencv feature extraction sift
Dictionary tree prefix tree trie
Retinaface: single stage dense face localization in the wild
CV learning notes alexnet
Development of intelligent charging pile (I): overview of the overall design of the system
LeetCode - 508. Sum of subtree elements with the most occurrences (traversal of binary tree)
yocto 技术分享第四期:自定义增加软件包支持
The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
随机推荐
LeetCode - 933 最近的请求次数
CV learning notes - camera model (Euclidean transformation and affine transformation)
LeetCode - 508. 出现次数最多的子树元素和 (二叉树的遍历)
There is no shortcut to learning and development, and there is almost no situation that you can learn faster by leading the way
Emballage automatique et déballage compris? Quel est le principe?
2.1 Dynamic programming and case study: Jack‘s car rental
20220610其他:任务调度器
Of course, the most widely used 8-bit single chip microcomputer is also the single chip microcomputer that beginners are most easy to learn
STM32 general timer output PWM control steering gear
Leetcode - 933 number of recent requests
Retinaface: single stage dense face localization in the wild
LeetCode - 895 最大频率栈(设计- 哈希表+优先队列 哈希表 + 栈) *
Application of 51 single chip microcomputer timer
4G module initialization of charge point design
el-table X轴方向(横向)滚动条默认滑到右边
2021-10-28
Not many people can finally bring their interests to college graduation
CV learning notes - BP neural network training example (including detailed calculation process and formula derivation)
ADS simulation design of class AB RF power amplifier
Circular queue related design and implementation reference 1