# Category Archives: Data Structures

You are given two integers N and M (M ≤ N), the task is to create an array of length N following the below-given conditions.… Read More
Construct a matrix whose each row contains N 1’s and each column contains M 1’s. Examples: Input: N = 3, M = 4Output:1 1 11… Read More
Given a string S consisting N digits, the task is to find the minimum number of deletions such that the bitwise Xor of any two… Read More
Given a string S of size N. The task is to find the number of Invalid characters. Index i (0 ≤ i < N) is… Read More
Given two arrays arr1[] and arr2[] of size N and M (M < N) add all elements of arr2[] in all possible subarrays of arr1[]… Read More
Given the root of an n-ary tree, the task is to find the number of subtrees that have duplicates in the n-ary tree. Two trees… Read More
Given an arr[] of length N, the task is to find the smallest possible sum of the array when we can subtract 1 and 2… Read More
A graph is a type of non-linear data structure that has two types of components “Vertices” (nodes) and “edges”. It contains a set of vertices… Read More
Given 2 arrays arr1[] and arr2[], of size N and M respectively, the task is to find a pair of value (say a and b)… Read More
What is Heap? A Heap is a special Tree-based data structure in which the tree is a complete binary tree. Types of Heap Data Structure:… Read More
Given an array a[] of 2*N integers, The task is to make the array a[] of size N i.e, reducing it to half size such… Read More
Given two arrays X[] and Y[] of length N each. You can shift from X[] to Y[] at most once. The task is to output… Read More
Given a binary string S consisting of ‘0‘ and ‘1‘ only, the task is to find the maximum possible number of “10” subsequences by replacing… Read More
Given two strings A and B which are permutations of each other. The task is to find the minimum number of rotations required to delete… Read More
Prerequisite:  SORT command in Linux/Unix with examples The SORT command in the Linux operating system is used for sorting. It can be done either for… Read More