Coding

Dot Product of Two Sparse Vectors

Calculate the dot product of two sparse vectors.

Input: nums1 = [0,1,0,0,2], nums2 = [0,0,0,0,5]

Output: 10

Explanation: Multiplies the aligned non-zero values (2 * 5) and ignores all the zeros, yielding a dot product of 10.

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

No answers yet

Be the first to share your approach to this question

Practice More Questions