Pergunta de entrevista da empresa Yahoo Japan

Implement a data structure in Swift that supports the following operations. Then, perform all operations given by input n and output an array which contains the results. Note that the input / may include undefined operations which should be ignored. • void add(K key, V value); // Add items that match the key and value to the data structure. Overwrite the value if the key already exists. • V get(K key); // Returns the value of the item that matches the key. Return '-1' if no item has been found or when an exception occurred. • V remove(K key); // Returns the value of the item that matches the key and then removes it from the data structure. Return '-1' if no item has been found or when an exception occurred. • void evict(); // Remove the eldest entry(the least recently accessed (add or get) entry) • void exit(); // Stops receiving new inputs and quits.