Category Archives: Arrays

Given two sorted arrays, find their union and intersection. Example:Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the… Read More
Given an array arr[] of integers, find out the maximum difference between any two elements such that larger element appears after the smaller number. … Read More
Question: Write an efficient program for printing k largest elements in an array. Elements in an array can be in any order.For example, if… Read More
You are given an array of 0s and 1s in random order. Segregate 0s on left side and 1s on right side of the array… Read More
Write a C function to return minimum and maximum in an array. Your program should make the minimum number of comparisons.  Recommended: Please try your… Read More
Question: Write a C function to find if a given integer x appears more than n/2 times in a sorted array of n integers. Basically, we… Read More
Write an efficient C program to find smallest and second smallest element in an array.  Become a success story instead of just reading about them.… Read More
Question: An Array of integers is given, both +ve and -ve. You need to find the two elements such that their sum is closest to… Read More
Inversion Count for an array indicates – how far (or close) the array is from being sorted. If the array is already sorted, then… Read More
Print the elements of an array in the decreasing frequency if 2 numbers have same frequency then print the one which came first.  Examples:  Become a… Read More
Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its… Read More
Given an array of positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be… Read More
Write a function rotate(ar[], d, n) that rotates arr[] of size n by d elements.  Attention reader! Don’t stop learning now. Get hold of all… Read More
Write a function rotate(arr[], d, n) that rotates arr[] of size n by d elements. Example: We provide nothing but the best curated videos and… Read More
Write a function rotate(arr[], d, n) that rotates arr[] of size n by d elements. Example : Attention reader! Don’t stop learning now. Get hold… Read More