Sollicitatievraag bij Peloton Interactive

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

Antwoord op sollicitatievraag

Anoniem

24 mei 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.