518.Sum of Two Numbers
Easy
Given two integers
a and b, return their sum.
The point here is the variableVariableA named storage slot that holds a value of a fixed type (such as int) so it can be used later.: a named box that holds a value. The first solution stores the answer in a variable before returning it; the second returns the expression directly. Both are correct — storing first is handy when you want to print or reuse the value, returning directly is shorter. The constraints keep the sum safely inside the range an int can hold, so there is no overflowInteger OverflowWhen a result is too large for its type, so it wraps around to a wrong (often negative) value..
Example 1:
Input: a = 12, b = 30
Output: 42
Example 2:
Input: a = -8, b = 3
Output: -5
+ 5 hidden test cases run on Submit.
Constraints:
- ●
-100000000 ≤ a, b ≤ 100000000
a =
12
b =
30