Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

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 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We 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.

- Bond February 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Best Answer

- Anonymous March 02, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The way we want to store the data depends on the type of queries we want to perform on them isnt it?

- Anonymous March 02, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think it should be a trie.

- Myth March 03, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Tries are not memory efficient structures. In fact they're much bigger than the data they carry.

Each phone number can be represented by 34 bit unsigned number. Bit pack these into 32 bit numbers. You'll save almost half the space from the 64 bit array solution.

- Baris March 04, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More