Question d’entretien chez Yahoo

Design a data structure to store sparse 2D matrix which contains only 0 or 1. then write function to add 2 such matrix.

Réponses aux questions d'entretien

Utilisateur anonyme

28 nov. 2010

use run-length encoding.

Utilisateur anonyme

23 févr. 2011

store each row as a decimal for ex: if the row is 1011 -> store it as 13!

Utilisateur anonyme

26 févr. 2011

Since all values are mod 2 you can pack 64 entries together into on int64_t. You can then add two matrices by XORing each entry.

Utilisateur anonyme

30 oct. 2010

I first proposed to use array to remember each 1 location. then find out it is quite expensive to do the addition. with the interviewer's help, I result in using hash table. then I was asked to write hash function. It was quite challenge for me. But the interviewer was really nice and very helpful to push me to the limit.