Machine Learning, AI and Programming

Tag: O(1) deletion

Leetcode : Design O(1) data structure for insertion, deletion and get random

Problem Statement Solution: It is pretty obvious that O(1) insertion and removal can be designed using a Set or Hash-Map or a Doubly Linked List. When duplicates are prohibited, using a Set() data structure is very convenient, but when duplicates are allowed we cannot use Set. Instead we can use Hash-Map. The key of the Hash-Map are the unique integers while the values are the count of each integer. While […]

Continue Reading →