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

1 answer published. Last candidate submission on May 21 2026, 8:59am PDT. Interview question asked to Software Engineers interviewing at Aircall, Bolt, 3M and other companies. Original question asked: Dot Product of Two Sparse Vectors. Question last reported by a candidate interviewing at thredUP for a Software Engineer interview on Oct 20 2026, 5:59pm PDT.