Create a cache for looking up prices of books identified by their ISBN. You implement support lookup, insert, and remove methods. Use the Least Recently Used (LRU) policy for cache eviction. If an ISBN si already present, insert should not change the price, but it should update the entry to be the most recently used entry. Lookup should also update that entry to be the most recently used entry.
Hint:Amortize the cost of deletion. Alternatively, use an auxiliary data structure.
Write a program which takes text for an anonymous letter and in the character set the number of times and determines if it is possible to write the anonymous letter using the magazine.
The anonymous letter can be written using the magazine if for each character in the anonymous letter, the number of times it appears in the anonymous letter is no more than the number of times it appears in the magazine.
Hint: Count the number of distinct characters appearing in the letter.
Consider the problem of designing an online calendaring application. One component of the design is to render the calendar, i.e., display it visually.
Suppose each day consists of a number of events, where an event is specified as a start time and a finish time. Individual events for a day are to be rendered as non-overlapping rectangular regions whose sides are parallel to the X- and Y- axes. Let the X-axis correspond to time. If an event starts at time b and ends at time e, the upper and lower sides of its corresponding rectangle must be at b and e, respectively.