Problem
You get two integers a and b. Return the sum of a and b. Do not use the + or - operators.
The integers can be negative. Bit operations can help. A bit operation works on the binary digits of a number, for example AND, OR, XOR and shift.
Example 1
- Input:
- a = 5, b = 9
- Output:
- 14
Example 2
- Input:
- a = -7, b = 3
- Output:
- -4
- Explanation:
- The sum of -7 and 3 is -4.
Example 3
- Input:
- a = -6, b = -10
- Output:
- -16
Constraints
- -1000 <= a, b <= 1000
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Meta
Leetcode 371. Sum of Two Integers
Reported Jun 13, 2025 · 2 source reports
SENIOR, STAFF
Source snapshot: Nov 12, 2026
View source