Answer: Confluent SWE Interview Question 2024 September | Design | on-campus

Answer · Posted Jun 2026

Solution 1: RandomizedSet — ArrayList + HashMap Design Approach To implement all operations (insert, remove, and getRandom) in average O(1) time: A **HashMap** supports O(1) inserts and deletes, but does not support O(1) random retrieval because we cannot index map keys directly. An **ArrayList** supports O(1) inserts (at the end) and O(1) random index access (via a random integer generator), but removing an arbitrary element from the middle takes O(N) time due to element shifting. We can combine both: Use ...

The full answer & interview discussion are available to premium members.

Log in Create a free account