Google | Onsite | Design data structure with getMinValue API
1965
Jun 02, 2019
Jul 13, 2019

Design a data structure with the following operations:

add(value);
remove(value);
get(value);
getMinValue(); // return the minimum value in data set

Follow-up:
Implement

getLatestValue(); // return the value inserted last

Example:

/* initialy data set is empty */
add(2);
add(3);
add(1);
getLatestValue(); // return 1
getMinValue(); // return 1
remove(1);
getLatestValue(); // return 3
getMinValue(); // return 2
Comments (10)