Professional Documents
Culture Documents
• You have to design a Cache .., expiration time is given along with the priority data needs to be
kept .. You have to design the Cache
• You should have knowledge about Caching , Data Structure to optimize the problem & Basic
fundamental.. Plain/ Simple Cache will not do
• Eviction should be based upon expiration then priority like that you have to design
• Glassdoor also has the same question but the solution is not present..
2.
• Developing a component using DSA
• LRU case
• They will be assessing based upon these parameters;
• How you handle edge case
• How you used DS & collection
• How you implement the solution
• Link for LRU Preparation: https://www.geeksforgeeks.org/lru-cache-implementation/
3.
• We need to evict an expire item
• Least possible used item
• How to implement hashmap
• How to find index in array
• How does hashing work
• How to manage collusion
• How to implement heap
• Link list
• LRU
4. LRU Case is all about these 3 cases - Questions would be based upon these 3 cases each;
• Expiration
• Priority
• Least used / recently used
• You have to design a Cache .., expiration time is given along with the priority data needs to be
kept .. You have to design the Cache
• You should have knowledge about Caching , Data Structure to optimize the problem & Basic
fundamental.. Plain/ Simple Cache will not do
• Eviction should be based upon expiration then priority like that you have to design
• And the eviction with full traversal won't work, you need to optimize finding the eviction node
further.
• I used a priority queue and pushed items based on the expiration, which will order the elements
with respect to expiration value.
• Learning more about the working of priority queue would help solving the task.
5.
• Priority expiration cache
• How to add items into the cache
• Update items into the cache
• How the cache will work if the cache is full
• Which item you will remove
• Mostly explanation with pseudo code
6.
List of books, list of Genre of books and book ratings was given, all list were of equal length.
book[], genre[], rating[] of equal length n
7.
// You have been given the task to develop a system that manages ratings of different books from
various genres. You need to implement a class, BookRatings, which can perform the following tasks:
// Initialise the System : The system should be initialised with three arrays - books (representing the
book titles), genres (representing the corresponding genres of the books), and ratings (representing
the initial ratings of the books). All arrays will be of length n.
// Modify the Rating of a Book : The system should be able to modify the rating of any given book.
// Return the Highest Rated Book : The system should be able to return the highest rated book for a
given genre. If there is a tie in ratings, return the lexicographically smaller book name.
// Method Signatures:
// void changeRating(String book, int newRating): Changes the rating of the book.
// String highestRated(String genre): Returns the name of the highest-rated book of the given genre.
//Constraints :
// n == books.length == genres.length == ratings.length
// Book will be the name of a book in the system across all calls to changeRating.
// Genre will be a genre of at least one book in the system across all calls to highestRated.
// Example 1:
// BookRatings bookRatings = new BookRatings(
// ["The Hobbit", "Harry Potter", "The Lord of the Rings", "Pride and Prejudice", "To Kill a
Mockingbird", "The Great Gatsby"],