I have one problem statement: Suppose there is Employee
class and a class has to be designed which provides get and put methods to access and add employees. Employee
class is a third party class so we can't make changes in it. There is a memory limit like max 50k employees can be stored. Now if while adding employee if memory limit is reached then remove one employee by following any of the below approaches and add the new employee:
- on the basis of access frequency
- on the basis of timestamp. one with the old timestamp should be removed
I can think of taking two hashmaps: - one for storing employee objects and one with the employees with key and timestamp or frequency as value.
But this is not the optimal solution. Please provide the valuable suggestions on which data structure can be used to solve this problem.