DATA STRUCTURE


Longest Subarray with Contiguous Elements

Longest Subarray with Contiguous Elements

Problem Given an array of distinct integers, find the length of the longest subarray, which cont…

Find the smallest subarray length whose sum of elements is >= k

Find the smallest subarray length whose sum of elements is >= k

Find the smallest subarray length whose sum of elements is >= k Problem Given an array of …

Find maximum profit earned by buying and selling shares any number of times

Find maximum profit earned by buying and selling shares any number of times

Problem You are provided an array of prices, where prices[i] represents the current price of a s…

Find Minimum Platforms Needed to Avoid Delay in the Train Arrival

Find Minimum Platforms Needed to Avoid Delay in the Train Arrival

Problem The objective is to identify the minimal number of train platforms necessary for the rai…

Find Maximum Length Subarray Having an Equal Number of 0’s and 1’s

Find Maximum Length Subarray Having an Equal Number of 0’s and 1’s

Problem Given a binary array nums, return the maximum length of a contiguous subarray with an eq…

Sort an array 0s, 1s and 2s (Dutch National Flag Problem)

Sort an array 0s, 1s and 2s (Dutch National Flag Problem)

Problem Given an array containing only 0s, 1s and 2s. Write an efficient algorithm to sort the a…

Maximum Difference Between Two Elements Such that Larger Element Appears After the Smaller Number

Maximum Difference Between Two Elements Such that Larger Element Appears After the Smaller Number

Problem Find the maximum difference between two array elements such that the bigger element appe…

Find Maximum Subarray Sum

Find Maximum Subarray Sum

Problem The objective is to find the elements of a continuous subarray nums of integers that hav…

Maximum Sum Circular Subarray

Maximum Sum Circular Subarray

Problem Given a circular integer array nums of length n, return the maximum possible sum of a no…

Subarray with Sum k

Subarray with Sum k

Problem Given an unsorted array arr of size N, find a contiguous subarray that adds to a given n…

Check if a Binary Tree is Height-Balanced or Not

Check if a Binary Tree is Height-Balanced or Not

Problem Given a binary tree. You need to check if it is height-balanced or not. A tree is heigh…

Convert a Binary Tree to Its Mirror Tree

Convert a Binary Tree to Its Mirror Tree

A binary tree is an important data structure. It has numerous applications in programming. A binary…