Tutorialmath
Sum of Two Integers
- Memory limit
- 256 MB
- Correctness time limit
- 10000 ms
- Acceptance
- 100.0%
- Solvers
- 1
You are given integers a and b. Return their sum.
Problems on this site are function style: you do not read input or print output. The values arrive as the
parameters of solution, and whatever the function returns is compared with the answer. In Python, for example:
def solution(a: int, b: int) -> int:
return a + b
Examples
| a | b | result |
|---|---|---|
1 | 2 | 3 |
-5 | 8 | 3 |
0 | 0 | 0 |
Example 1 — 1 + 2 = 3.
Example 2 — Negative numbers add the same way: -5 + 8 = 3.
Example 3 — 0 + 0 = 0.
This is a tutorial problem: there are no performance tests, just return the correct value.
Function signature
solution(a: int, b: int) → int
Constraints
-
a,b
Expected complexity
- Time
- O(1)
- Space
- O(1)
Examples
| a | b | Expected |
|---|---|---|
1 | 2 | 3 |
-5 | 8 | 3 |
0 | 0 | 0 |
Hint
Hint
Just return a + b. Printing the value does not count; the function has to return it.
Time limits per language
| Language | Efficiency time limit | |
|---|---|---|
| C (GCC, gnu17) | 200 ms | estimated |
| C++ (GCC, gnu++23) | 200 ms | derived |
| Python 3.13 | 1000 ms | derived |
| Java 25 | 1000 ms | derived |
| Kotlin 2.4 (JVM) | 1200 ms | estimated |
| C# 14 (.NET 10) | 1200 ms | estimated |
Test groups
| Group | Weight | Tests | Visibility |
|---|---|---|---|
| sample | 0 | 3 | inputs and outputs |
| correctness | 100 | 12 | verdict only |