Array Sum and Product Equation
EasyP3Coding
Let S be the sum of the elements of arr and P their product. Return 7 * S + 9 * P.
Example 1
- Input
- arr = [1,2,3]
- Output
- 96
- Why
- S = 6, P = 6, so 7*6 + 9*6 = 96.
Example 2
- Input
- arr = [5]
- Output
- 80
Example 3
- Input
- arr = [0,4,5]
- Output
- 63
Constraints
- 1 <= arr.length <= 10
- -20 <= arr[i] <= 20
- The product fits in 2^53.
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.