DATA STRUCTURE


Find the closest pair from two arrays

Find the closest pair from two arrays

Problem Given two sorted arrays and an integer X, find one number from each array such that the …

Find all symmetric pairs in an array of pairs

Find all symmetric pairs in an array of pairs

Problem Given an array of pairs, find all symmetric pairs in it. Symmetric pairs are two pairs (…

Find an index of the maximum occurring element with equal probability

Find an index of the maximum occurring element with equal probability

Problem Given an array of integers, find the most occurring element of the array and return any …

Find the minimum difference between the index of two given elements present in an array

Find the minimum difference between the index of two given elements present in an array

Problem Given two integers, find the minimum difference between their index in a given array in …

Group elements of an array based on their first occurrence

Group elements of an array based on their first occurrence

Problem Given an unsorted array, the task is to group multiple occurrences of individual element…

Smallest Subtree with All Deepest Nodes

Smallest Subtree with All Deepest Nodes

Problem Given a binary tree, return the smallest subtree that has all the deepest nodes of the o…

How to Generate Random Strings and Passwords in Python?

How to Generate Random Strings and Passwords in Python?

To generate random data in Python, we generally use Python's random module.  And in this t…

Quicksort algorithm using Hoare’s partitioning scheme

Quicksort algorithm using Hoare’s partitioning scheme

Problem Implement QuickSort using Hoare’s partition scheme. Approach Hoare's Par…

Problems solved using partitioning logic of Quicksort

Problems solved using partitioning logic of Quicksort

Problem What are some of the problems that can be solved using the partition logic of quicksort?…

In-place vs out-of-place algorithms

In-place vs out-of-place algorithms

In-Place algorithms This is a category of the algorithms that do not consume any extra space in …

Sort elements by their frequency and index

Sort elements by their frequency and index

Problem  Given an array of integers, sort them by their frequencies. If two elements have t…

Find minimum and maximum with minimum number of comparisons

Find minimum and maximum with minimum number of comparisons

Problem Given an array of integers, find the minimum and maximum elements in it with a minimum n…