Interview Question
Country: United States
Interview Type: In-Person
Can elaborate the scope of the system we are trying to design? Is the interviewer looking abstract DS or a OOD?
To me, best would be to use maps thus reduce coding to find out the destination address. It would be sometinh like...
PostalSystem <Map (<pincode>,<Map(<address>,<message>)>)>
This is basic you can expand including separate cover map for state country etc
Do you mean the efficient presentation of all available addresses to be used for look up of the specific given address?
- Anonymous June 30, 2014I believe the answer would be Trie of cities, where each city will hold Trie of streets, where each street will hold array of size equals to number of houses - providing thus 0(1) look up table.