VMware Interview Question: Write the implementation for ... | Glassdoor

Interview Question

Senior Member of Technical Staff Interview Palo Alto, CA

Write the implementation for LRUMap.

technical, algorithm

Interview Answer

1 Answer


LRU stands for Least Recently Used. LRUMap uses the LRU algorithm to delete the least recently used value in the map (presumably full) to make space for the newest entry.
Implementation using Java:

import java.util.Collections;
import java.util.Map;
import org.apache.commons.collections.map.LRUMap;

public class LRUSample {

    private static final int MAX_CAPACITY = 5;

    public static void main(String[] args) {
        Map lruMap = (Map) Collections.synchronizedMap(new LRUMap(MAX_CAPACITY));

        for(int i = 0; i

Anonymous on Apr 28, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.