Dot Product
Start Timer
0:00:00
Given two vectors nums1 and nums2 of equal length, return their dot product.
The dot product of two vectors is defined as:
You must implement the solution without using built-in functions like numpy.dot.
Example 1
Input
nums1 = [1,2,3], nums2 = [4,5,6]
def dotProduct(nums1, nums2) -> 32
Explanation: 1*4 + 2*5 + 3*6 = 32
Example 2
Input
nums1 = [0,1,0], nums2 = [1,0,1]
def dotProduct(nums1, nums2) -> 0
Explanation: 0*1 + 1*0 + 0*1 = 0
Constraints
nums1andnums2are lists of integers of the same lengthn1 <= n <= 10^4-100 <= nums1[i], nums2[i] <= 100
.
.
.
.
.
.
.
.
.
Comments