Huge collection of data structures and algorithms problems on various topics like arrays, dynamic programming, linked lists, graphs, heap, bit manipulation, strings, stack, queue, backtracking, sorting, and advanced data structures like Trie, Treap.

Given an integer array, shrink it by removing adjacent triplets that satisfy the given constraints and return the total number of elements in the resultant array.

Given a BST, count the total number of nodes that lie within a given range. For example, the total number of nodes in range `[12, 20]` in the following BST are 12, 15, 18, and 20.

An Eulerian trail (or Eulerian path) is a path in a graph that visits every edge exactly once. Given a directed graph, check whether it has an Eulerian path or not.

Given a list of non-negative integers, find the minimum number of merge operations to make it a palindrome. A merge operation can only be performed on two adjacent elements. The result of a merge operation is that the two adjacent elements are replaced with their sum.

Given two height-balanced binary search trees, in-place merge them into a single balanced binary search tree. For each node of a height-balanced tree, the difference between its left and right subtree height is at most 1.

Given an array and a positive number `k`, check whether the array contains any duplicate elements within the range `k`. If `k` is more than the array's size, the solution should check for duplicates in the complete array.

Given an array of distinct integers `arr`, shuffle it according to the given order of elements `pos`. i.e., if `pos[i] = j`, then update `arr[j] = arr[i]` for every index `i`.

Given a sorted integer array, find a pair in it having an absolute minimum sum. The idea is to maintain search space by maintaining two indexes (`low` and `high`) that initially points to two endpoints of the array.

Given an integer array, find the index of the maximum occurring element with an equal probability. For example, consider the input: `{4, 3, 6, 8, 4, 6, 2, 4, 5, 9, 7, 4}`.

Given an integer array, check if only consecutive integers form the array. For an array to contain consecutive integers, the difference between the maximum and minimum element in it should be exactly `n-1`.

Given an integer array, find subarrays with a given sum in it. Please note that the problem specifically targets subarrays that are contiguous and inherently maintains the order of elements.

Given two arrays of positive integers, add their elements into a new array. The solution should add both arrays, one by one starting from the 0th index, and split the sum into individual digits if it is a 2–digit number

Given an integer array, find the maximum product of two integers in it. For example, consider array `{-10, -3, 5, 6, -2}`. The maximum product is the `(-10, -3)` or `(5, 6)` pair.

Given an integer array, find the maximum length subarray having a given sum. The problem differs from the problem of finding the maximum length subsequence with given sum.

Given an integer array, find the equilibrium index in it. For an array `A` consisting `n` elements, index `i` is an equilibrium index if the sum of elements of subarray `A[0…i-1]` is equal to the sum of elements of subarray `A[i+1…n-1]`.

Given an unsorted integer array, find a pair with the given sum in it... There are several methods to solve this problem using brute-force, sorting, and hashing.

Given an array containing only 0's, 1's, and 2's, sort it in linear time and using constant space.. A simple solution would be to perform a counting sort..