I'll trace through a sequence. Start with an empty structure: map = {}, arr = [].
insert(10): arr becomes [10], map becomes {10: 0}. insert(20): arr becomes [10, 20], map becomes {10: 0, 20: 1}. insert(30): arr becomes [10, 20, 30], map becomes {10: 0, 20: 1, 30: 2}.
Now remove(20): look up index . Swap arr[1] with arr[2], giving [10, 30, 20]. Update map: {10: 0, 30: 1}. Pop the last element. Final: arr = [10, 30].
Each operation does a constant number of map lookups, array accesses, and swaps. That's average time per operation. Space is for storing elements across the map and array.