Coupon Dunia Interview Question for Software Developers


Country: India
Interview Type: In-Person




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

lets analyze the problem.

Desired Functionality:
1. Storing: given filename, with list of chunks (series of 8x8=64 bits), we need to store them.
2. Fetching: given filename, we need to first check it exists in our DB, and then get all its chunks.
3. Deleting: given filename, we need to find its data as in Fetching, and delete it carefully

Criteria and things to consider:
1. low time complexity of each function
2. avoid chunks duplications
3. avoid dangling references
4. memory considerations

suggested Solution:
we can use Hash map which map filename to list of references to corresponding chunks.
the chunks wll be stored in balances tree, sorted by binary value, for O(logm) search.
since several different files can point the same chunks, we will use reference count in each node in the
tree.
this way, we can store file by inserting it to hash map. for every chunk we will check the tree if exsits,
if not - create one and push, if yes - just refernce to it from the list in the hashmap.
fetching is easy - just lookup in hashmap and return list of corresponfing chunks.
deleting: go to the hash entry, iterate chunks references and decrease ref count of every chunk node by 1,
if zero is reach then remove from tree. at last remove from hash.

Note that we could save the chunks themselves also in a hash, but i chose to use tree since i assume the number
of total chunks can be very large, and it will be not reasonable to store it on contigous memory segment.

- MRLevis21 November 24, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

hey bro, can u send the code if possible?

- uday September 15, 2020 | 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