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.

Community Answers

1 answer from the community

Unlock Full Access

Answer any un-answered question from our database to unlock all community answers for 30 days.

Give & Take

Practice More Questions

2 answers published. Last candidate submission on Nov 13 2026, 8:42am PDT. Interview question asked to Software Engineers interviewing at YouTube, Gemini, Cars24 and other companies. Original question asked: Dot Product of Two Sparse Vectors. Question last reported by a candidate interviewing at UberEats for a Software Engineer interview on Nov 1 2026, 11:56pm PDT.