Add Two Integers - Problem

Given two integers num1 and num2, return the sum of the two integers.

Constraints:

  • -100 ≤ num1, num2 ≤ 100

Input & Output

Example 1 — Basic Addition
$ Input: num1 = 12, num2 = 5
Output: 17
💡 Note: Simply add the two integers: 12 + 5 = 17
Example 2 — Negative Numbers
$ Input: num1 = -10, num2 = 4
Output: -6
💡 Note: Adding a positive to a negative: -10 + 4 = -6
Example 3 — Both Negative
$ Input: num1 = -1, num2 = -1
Output: -2
💡 Note: Adding two negatives: -1 + (-1) = -2

Constraints

  • -100 ≤ num1, num2 ≤ 100

Visualization

Tap to expand
Add Two Integers ProblemINPUTPROCESSOUTPUTnum1 = 12num2 = 512 + 517🎯 Key Insight: Addition is a fundamental O(1) operationNo complex algorithms needed - just use the + operator!
Understanding the Visualization
1
Input
Two integers: num1 = 12, num2 = 5
2
Process
Add the integers using + operator
3
Output
Return the sum: 17
Key Takeaway
🎯 Key Insight: Integer addition is already optimized - use the + operator directly
Asked in
Google 15 Amazon 12 Microsoft 10
125.0K Views
Very High Frequency
~2 min Avg. Time
4.5K Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen