Skip to content

Practice Add Two Integers

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2235
LeetCode Problem

Add Two Integers

Problem Statement

Return num1 + num2 for the supplied pair of integers. Negative inputs and zero use ordinary signed addition. Practice approach: This task needs one addition, not string conversion, carry simulation, or a linked list. With the stated bounds, the result fits in a signed 32-bit integer. Time and extra space are both O(1). Test opposite signs, two negatives, and a zero operand.

Source: Add Two Integers on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
num1 = 12, num2 = 5
Output
17

# Example 2

Input
num1 = -10, num2 = 4
Output
-6

Constraints

-100 <= num1, num2 <= 100

Related LeetCode Problems

Practice more problems similar to Add Two Integers.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.