Interview Question
Software Engineer / DevelopersWe have only 1 million numbers. Phone no are only 10 digits with max value 999-999-9999.
Why not use Array[ULong] for 64 bit architecture and Array[ULongLong] for 32 bit architecture. The max value that can be stored in 64 bit is +18,446,744,073,709,551,615 which is big enough for phone number.
Total space required = 64 bit * 1 million < 8MB and hence can be stored in memory.
by the way i would guess a trie..and i use a char to store each digit because they are 1 byte whereas short=2, int=4.
- woohoo February 28, 2011