Cart Total
EasyP3Coding
price[i] is the unit price of item i and quantity[i] how many of it are in the cart. Return the total cost, the sum of price[i] * quantity[i] over all items. Both arrays have the same length.
Example 1
- Input
- price = [10,20], quantity = [1,2]
- Output
- 50
- Why
- 10*1 + 20*2 = 50.
Example 2
- Input
- price = [5], quantity = [3]
- Output
- 15
Example 3
- Input
- price = [100,200,300], quantity = [0,0,0]
- Output
- 0
Constraints
- 1 <= price.length == quantity.length <= 10^4
- 0 <= price[i] <= 10^4
- 0 <= quantity[i] <= 10^3
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.