I was asked one Data Structure related question in phone interview and i struggled with that.
Problem was : For two vectors VectorA and VectorB, Its has integer values like
A = [1,0,0,0,4,0,1]
B= [ 0,0,0,0,3,0,0]
For Math Operation A*B = A1B1+A2B2+...+AnBn Return Result
For above Example, Answer will be 12 but this can scale upto millions of values.
How would you create Vector Data Structure thats holds all non zero values and scales for millions of data ?
Vector {
//Write your Data Structure Here
int product(Vector A, Vector B) {
}}