A fun problem: IndexedValues
This is a fun problem - how would you implement it?public interface IndexedValues<V> {
/**
* Inserts the specified value at the specified index. The same
* value may be inserted several times in the same collection.
*/
void insert(int index, V value);
/**
* Returns the index of the first occurrence of the specified value.
*
* @param min the returned index will be greater than or equal to this.
* @param max the returned index will be less than this.
* @return the index, or {@code null} if no such value exists in
* the requested range.
*/
int find(int min, int max, V value);
}
We've already implemented a solution but there's probably several interesting ones.