Peloton Interactive interview question

Implement a list-based data structure that performs inserts and deletes in constant time.

Interview Answer

Anonymous

24 May 2023

Use a list to store the items, use a dictionary to store the indices of each item in the list. Perform deletes by swapping the item at the end for the item to be deleted, and then truncating the list by 1 item.