Funcia
Tutorialmath

Sum of Two Integers

Memory limit
256 MB
Correctness time limit
10000 ms
Acceptance
100.0%
Solvers
1
0

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

abresult
123
-583
000

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

  • −1,000,000≤-1{,}000{,}000 \le a, b ≤1,000,000\le 1{,}000{,}000

Expected complexity

Time
O(1)
Space
O(1)

Examples

abExpected
123
-583
000

Hint

Hint

Just return a + b. Printing the value does not count; the function has to return it.

Time limits per language

LanguageEfficiency time limit
C (GCC, gnu17)200 msestimated
C++ (GCC, gnu++23)200 msderived
Python 3.131000 msderived
Java 251000 msderived
Kotlin 2.4 (JVM)1200 msestimated
C# 14 (.NET 10)1200 msestimated

Test groups

GroupWeightTestsVisibility
sample03inputs and outputs
correctness10012verdict only
Loading editor…
Log in to run or submit code.

No result yet. Run or submit your code.