Amazon Interview Question
Software Engineer / DevelopersI think a simple 1-D array would do. In that array just store the locations and their values of the sparse arrays as objects. If you like to multiply, we can use standard multiplication and can be cleverly designed to implement minimum number of steps, because of the sparseness of the array.
Link List are good for implementing sparse arrays because you need not store values that are not in the sparse arrays.
- DrEvil June 03, 2007