Find the Smallest Divisor given a Threshold Leetcode Solution

This post is on Find the Smallest Divisor given a Threshold Leetcode Solution Problem statement In the problem ” Find the Smallest Divisor Given a Threshold” we are given a nums array and a threshold value. A variable “result” is defined as the sum of all answers when elements in …

Read moreFind the Smallest Divisor given a Threshold Leetcode Solution

Minimum swaps required to bring all elements less than or equal to k together

The problem “Minimum swaps required to bring all elements less than or equal to k together” states that you have an integer array. The problem statement asks to find out the smallest count of swaps that will be required to get the elements together which are less than or equal …

Read moreMinimum swaps required to bring all elements less than or equal to k together

Insert Delete GetRandom

In Insert Delete GetRandom problem we need to design a data structure that supports all following operations in average¬†O(1)¬†time. insert(val): Inserts an item val to the set if not already present. remove(val): Removes an item val from the set if present. getRandom: Returns a random element from the current set …

Read moreInsert Delete GetRandom