top of page

Arrays
Welcome to the Arrays articles page. Find all the programs used to solve various problems using arrays. These articles will help you understand the first data structure on your DSA journey


Majority Element (n/3 times)
Problem Statement: Given an array of integers, find all elements that appear more than n/3 times. The algorithm should run in linear time...


Merge Two Sorted Arrays Without Extra Space
Problem Statement: Given two sorted arrays arr1 and arr2 of sizes n and m, respectively, merge them in such a way that the resulting...


Pascals Triangle
Problem Statement: Given an integer numRows, generate the first numRows of Pascal's Triangle. In Pascal's Triangle, each number is the...


Find the Row with the Maximum Number of 1’s
In this article, we will solve the problem of finding the row with the maximum number of 1’s in a binary matrix. Problem Statement: Given...


Print the Matrix in a Spiral Manner
In this article, we will solve the problem of printing a given 2D matrix in a spiral order. Problem Statement: Given a 2D matrix, write a...


Find Maximum Product Subarray
In this article, we will solve the problem of finding the maximum product subarray within a given array of integers. Problem...


Rearrange the Array in Alternating Positive and Negative Items
In this article, we will solve the problem of rearranging an array such that positive and negative numbers alternate. If there are extra...


Count Pairs with the Given Sum
In this article, we will solve the problem of counting the number of pairs in an array that sum up to a given target value. Problem...


Cyclically Rotate an Array by One
In this article, we will solve the problem of cyclically rotating an array by one position to the right. Problem Statement: Given an...


Chocolate Distribution Problem
In this article, we will look at the problem of distributing chocolate packets among students in such a way that the difference between...


Minimum Number of Jumps to Reach End
In this article, we will solve the problem of finding the minimum number of jumps required to reach the end of an array. This simply...


K'th Smallest Element in an Unsorted Array
In this article, we will solve the problem of finding the k'th smallest element in an unsorted array. This means that in an array, we...


Trapping Rainwater
In this article, we will solve the problem of calculating the amount of water that can be trapped after rainfall on a given map...


Stock Buy and Sell
In this article, we will solve the problem of determining the maximum profit that we can get from buying and selling a single stock given...


Find the Repeating and Missing Numbers
In this article, we will solve the problem of finding the repeating and missing numbers in a given array of integers using a hash map. So...


Merge Overlapping Sub-Intervals
In this article, we will solve the problem of merging overlapping sub-intervals. We are given an array of intervals, our task is to merge...


Find the Next Greater Permutation
In this article, our aim is to solve the problem of finding the next greater permutation for the array containing integers. The next...


Sort an Array of 0's, 1's and 2's
In this article, we aim to understand and solve the problem of sorting an array that contains 0, 1, and 2. This problem is also known as...


Maximum Consecutive Ones in an Array
In this article, we will solve the problem of finding the maximum number of consecutive 1s in a binary array that contains only 0s and...


Find the Element that occurs more than N/2 times
In this article, we will be solving a commonly asked question on arrays, which is the Majority Element problem. In this problem, we are...


Search in a Sorted 2D Matrix
In this article, we will be solving a 2D array search problem. So we are given a matrix of size N x M, where N and M represent the number...


Rotate a Matrix by 90 Degrees
In this article, we aim to solve the problem where we have to rotate a matrix given to us by 90 degrees. This simply means that we have...


Three Sum Problem
In this article, we will be solving another common problem on the array which is the 3 sum problem. Here, we are given an array of N...


Two Sum Problem
In this article, we will be solving a commonly asked question on the array which is the 2 sum problem. So in this problem, we are given...


Four Sum Problem
In this article, we will be solving a commonly asked question on arrays which is the 4 sum problem. In this problem, we are given an...


Remove Duplicates
In this article, we aim to solve the problem of removing duplicates from a sorted array. So this simply means that we have been given an...


Find the Missing Number
So in this article, we will be understanding how to find the missing number in an array. This simply means that we will have an array...


Find the Largest Element
In this article, we aim to solve the problem of finding the largest element from an array. So this simply means that we have been given...


Arrays
In this article, we will be understanding the concept of an array. So before understanding the technical aspect let us understand the...
bottom of page