Sparse Vector Dot Product

Programming Interview Hard 10 views
Back to Questions

Problem Description

Two sparse vectors are provided as list of index:value pairs. Build SparseVector class with dot(other). Output dot product.

Input Format

Line1: n (size) a (nonzero count). Next a lines: idx val. Next line: b (count). Next b lines: idx val.

Output Format

One integer dot.

Sample Test Case

Input:
5 2 0 1 3 4 2 0 2 4 3
Output:
2

Constraints

0

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next