Apple phone screen

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-08-21Added By Anonymous
Source: Link

Company: Apple
Role: ICT4
Interview Stage: Phone Screen
Location: Cupertino, CA
Year: unknown

Original Post Content:

This was Senior Software Engineer - Data Services (ASE) team, search solr team Cupertino, CA.
question:
given a List<List<SearchResult>> coming from different shard each list is sorted desc by the Doc Score we want to collect top N results for the user let say if the result have 1000 docs return the 100 highest docs for the user.
example: [ [10,8,9,7], [6,4,3,2,1] ....] so we want to return top say 5 docs so we need to take first 4 docs from list 1 [10,8,9,7] then 1 doc 6 from second list.

Also you can't insert all the results to the heap as the result might be too large (not sure why he put this constraint)
I used first a maxheap and insert the top docs of each list and then dequeue from the heap to collect, but this as you see will not be correct. The interviewer gave hint to use another index and check the heap and check the list. but couldn't come up with a solution in the last 10 minutes of the interview, not sure if it is fair to ask such a question in 30 minutes coding phone screen or it is away to disqualify people based on the interviewer bias.

Comments