A Very Big Sum
EasyP3Coding
Return the sum of all numbers in ar. Individual values can be as large as 10^10, so make sure the arithmetic does not overflow a 32-bit integer.
Example 1
- Input
- ar = [1000000001,1000000002,1000000003,1000000004,1000000005]
- Output
- 5000000015
- Why
- The sum is 5000000015, which does not fit in 32 bits.
Example 2
- Input
- ar = [5]
- Output
- 5
Example 3
- Input
- ar = [10000000000,10000000000,10000000000]
- Output
- 30000000000
Constraints
- 1 <= ar.length <= 10
- 1 <= ar[i] <= 10^10
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.