Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Last updated: Aug 2, 2022

Arrays

An array is the most primitive and frequently used data structure in the field of computer science. It has become the inspiration for several data structures such as lists and strings. An array is basically a collection of similar types of data items stored at contiguous memory locations. It helps us to store multiple items of the same data type together. They are also used to implement other data structures like Heaps, Stacks, Queues, etc. This category contains all of the information you need to know about arrays.
Difference between Array, Queue & Stack MEDIUM
In this blog, we'll learn about the differences between arrays, queue and stack.
How to Rearrange an Array such that arr[i]=i? EASY
This article will discuss how we can rearrange an array such that arr[i]=i.
Find the Number Occurring Odd Number of Times
Different ways to find a number with odd frequency in a group of numbers with even frequencies.
Leaders in an Array EASY
This article will discuss the Leaders in array problems and various ways to solve this problem.
Difference Between Array and String EASY
In this article, we will learn about the differences between arrays & strings, their declaration syntax, instantiation, and accessing elements with proper code examples to illustrate these concepts.
Max XOR of Two Numbers in an Array MEDIUM
Finding the Maximum XOR of two elements in an array is one of the most important interview problems. This article discusses the solution for this in C++, Java, and Python.
Missing Number in Array EASY
In this blog, we will learn about Missing Number in Array. We will write code in different languages for better understanding.
Sum of middle elements of two sorted arrays
This article will discuss the Sum of middle elements of two sorted arrays problem and various ways to solve this problem, starting from the brute force approach to the efficient approach.
Check loop in array according to given constraints MEDIUM
In this article, we will learn how to check loop in an array according to given constraints, along with the explanation, algorithm, and implementation.
How to take array input from user in java? EASY
In this blog, we will learn about How to take array input from user in java. We will learn about different ,methods for better understanding.
Difference Between Linear Array And A Record EASY
This article will provide an overview and discuss the significant what difference between linear array and a record is based on various parameters.
Find First K Natural Numbers Missing in the Given Array EASY
This blog covers finding the first k natural numbers in a given array.
For Each Loop EASY
In this article, you will go through the for each loop (also known as the for each loop), a control flow statement used to traverse entries in a collection.
Equilibrium Index of an Array EASY
This article covers an array based problem i.e. Equilibrium Index of an Array with different approaches and implementation in detail.
Pythagorean Triplet in an Array MEDIUM
In this article, we will discuss various approaches to finding out the presence of the Pythagorean Triplet in an array. We will also look at their code in different languages and their complexity analysis.
Javascript Program for Largest Sum Contiguous Subarray
This article will look at a javascript-based implementation of the solutions for the largest contiguous sum problem.
Find a rotation with maximum hamming distance EASY
In this article, we will discuss how to find a rotation with maximum hamming distance and understand the concept with examples in detail.
Sort An Array Containing 0’s, 1’s and 2’s MEDIUM
In this blog, we will discuss one problem related to sorting in which we will sort an array containing 0's, 1's, and 2's.
Find the Maximum Sum of i*arr[i] Among all Possible Rotations of an Array
This article finds the maximum sum of i*arr[i] among all possible rotations allowed on a given array.
Multiple left rotations of an array with O(1)
An array can be left rotated or right rotated. This article is majorly concerned with the left rotations of an array with O(1) time complexity.
Difference between Array and Structure EASY
Arrays and structures are data structures in programming. Explore the difference between arrays and structures in programming. Read on to learn more.
Reversal algorithm for right rotation of an array
This article deals with the reversal algorithm for right rotation of an array and its implementation, time and space complexities.
Reversal Algorithm for Array Rotation
This article discusses the Reversal Algorithm for Array rotation. It also calculates the time and additional space complexity of the algorithm.
Block Swap Algorithm for Array Rotation EASY
This blog discusses Block Swap Algorithm for array rotation, an algorithm to find the rotated array when we are given the array and the no of rotations.
Rotation Count
This blog discusses in detail Rotation Count, i.e., no of times a sorted array of distinct elements is rotated.
What Is Subarray With Given Sum? MEDIUM
In this article, we will discuss about what subarray is with the given sum.
Program for Array Rotation in Java MEDIUM
Explore effective array rotation techniques in programming. Learn how to optimize code, improve performance, and solve common challenges associated with array rotation.
Queries on Left and Right Circular shift on Array MEDIUM
In this article, we will discuss how to operate on left and right circular shifts on an Array and understand the concept with examples in detail.
The minimum number of elements to add to make median equals x
This current article will discuss the problem "Minimum number of elements to add to make median equals x." We will discuss this problem in the best possible way.
Given a Sorted and Rotated Array, Find if There is a Pair with a Given Sum EASY
In this article, we will discuss two approaches of solving a given sorted and rotated array to find if there is a pair with a given sum.
Segregate 0s and 1s in an Array
In this article, we will discuss the segregating of 0s and 1s in a binary array. We will look also look at the problem statement in detail followed by its various approaches, code, and complexities.
Rearrange positive and negative using the inbuilt sort function
In this article, we will discuss a very interesting problem in which we have to rearrange such that all negative numbers come before positive numbers, and the order of elements needs to remain the same.
Rearrange the array such that the even index elements are smaller and the odd index elements are greater
In this article, we will discuss the problem of rearranging an array such that the even index elements are smaller and the odd index elements are greater.
Rearrange array such that arr[i] >= arr[j] if "i" is even and arr[i]<=arr[j] if "i" is odd and j < i EASY
This blog will discuss a problem of array rearrangement such that arr[i] >= arr[j] if "i" is even and arr[i]<=arr[j] if "i" is odd and j < i.
Rearrange an array in order - Smallest, Largest, 2nd Smallest, 2nd Largest and so on EASY
In this article, we will learn to reorder an array by placing the smallest number first, the largest number in second, the second smallest in third, the second-largest in fourth, etc.
Rearrange Array such that Even Positioned are Greater than Odd EASY
In this article, we will learn to rearrange an array such that the even positions are greater than the odd ones. We will implement different approaches in C++ and Java.
Replace every array element by multiplication of previous and next elements EASY
In this article, we will discuss how to replace every array element by multiplication of previous and next elements, and understand the concept with examples, in detail.
Positive elements at even and negative at odd positions MEDIUM
In this article, we will discuss how to arrange elements of an array such that positive elements occur at even and negative at odd positions; we will discuss its brute force approach and optimized solution.
Array Reordering Using Given Indexes EASY
In this article, we will learn to reorder an array using another array with given indexes. We will implement different approaches in C++ and Java.
Merging Two Sorted Arrays MEDIUM
This article discusses merging two sorted arrays using JavaScript. We will see various methods for merging two sorted arrays and the implementation in C++.
Form Minimum Number from Given Sequence MEDIUM
In this article, we will discuss how to form a minimum number from a given sequence.
Move All Negative Elements to the End in Order With Extra Space Allowed EASY
This blog mainly focuses on the problem of moving all the negative elements to the end of the array in order with extra space allowed. We will discuss different approaches to solve this problem with a proper explanation and flow diagram.
Making elements of two arrays identical with minimum increment/decrement MEDIUM
In this blog, we'll alternate the elements to convert one number into another by adding or subtracting one and getting the result.
Arrange Given Numbers to Form the Biggest Number EASY
This blog mainly focuses on the problem, namely Arrange Given Numbers to Form the Biggest Number. We will discuss different solutions to solve this problem with a proper explanation and implementation.
Three-way Partitioning of an Array Around a Given Range EASY
The goal of this problem is to divide the array into three parts by partitioning it around the range. The three sets' elements can appear in any order. You must return the array that has been modified.
Split the array and add the first part to the end
In this blog, we will look at an array question in which we split the array and add the first part to the end.
Shuffle 2n integers as a1-b1-a2-b2-a3-b3-...bn without using extra space EASY
In this article, we will be discussing how to create a shuffled array of 2n integers as a1-b1-a2-b2-a3-b3-...bn without using extra space.
Generate all Possible Sorted Arrays from Alternate Elements of Two Given Sorted Arrays HARD
In this article, we will discuss how to generate all possible sorted arrays from alternate elements of two given sorted arrays.
Smallest subarray with sum greater than a given value MEDIUM
In this blog, We will see the solution to the problem smallest Subarray with a sum greater than a given value
Program for Mean and Median of an unsorted array
In this article, we will discuss the finding of the mean and median from an unsorted array. We will look also look at the problem statement in detail followed by its algorithm and implementation.
Maximum difference between a group of k-elements and rest of the array
This current article will discuss the problem "Given an array of size n and a number k, we need to find all elements that appear more than n/k times." We will discuss this problem in the best possible way.
Maximum difference between two elements such that larger element appears after the smaller number MEDIUM
In this blog, we will cover the problem of finding the maximum difference between two elements such that the larger element appears after the smaller number and will discuss its time and space complexities.
Given an array arr[], find the maximum j – i such that arr[j] > arr[i] MEDIUM
This blog will cover the problem of finding the maximum value of j-i such that arr[j] > arr[i] and its time and space complexities.
Author coldz
0 upvotes
K-th Largest Sum Contiguous Subarray MEDIUM
In this blog, we will find the K-th largest sum contiguous subarray.
K maximum sums of overlapping contiguous sub-arrays HARD
In this article, we will discuss the problem of K maximum sums of overlapping contiguous sub-arrays
K maximum sums of non-overlapping contiguous sub-arrays MEDIUM
In this article, we will discuss how to find the ‘k’ maximum sums of non-overlapping contiguous sub-arrays, in detail.
Moore’s Voting Algorithm
This blog will cover Moore’s Voting algorithm to find the Majority Element and discuss its Time and Space complexity.
Find the minimum number of merge operations to make an array palindrome
This article explains how to find the minimum number of merge operations to make an array palindrome, how it can be implemented, and the code to solve it.
Find Zeroes to be Flipped, so that Number of Consecutive 1's is Maximised with K Maximum Flips
In this article, we will understand how to find zeroes to be flipped, so that number of consecutive 1's is maximised with k maximum flips.
Number of subsets with product less than k MEDIUM
This blog will give you detailed explanation and implementation of the approach to find the number of subsets with product less than k.
Maximize elements using another array EASY
In this blog, we will discuss different approaches to maximize elements using another array. Then we will discuss their algorithms, pseudo-codes, and complexities analysis.
Minimum product of k integers in an array of positive Integers EASY
In this blog, we will find the minimum product of k integers in an array of positive integers.
Shuffle an array using Fisher-Yates shuffle Algorithm MEDIUM
This article will discuss how to shuffle an array using the Fisher-Yates algorithm in O(n) time complexity.
Count Square Submatrices with All Ones MEDIUM
This article revolves around the coding problem, which says Count Square Submatrices with all ones.
Author Alisha
2 upvotes
Matrix probability problem MEDIUM
In this article, we will learn in brief about two-dimensional arrays known as matrices. We will also discuss a matrix probability problem using the idea of Depth First Search (DFS).
Search in a 2-D Matrix which is sorted row-wise and column-wise.
In this article, we will discuss the problem of checking if the given number is present in the row-wise and column-wise sorted matrix
Size of all Connected Non-Empty Cell of Matrix
In this blog, we will solve the Matrix problem, in which we have to count the size of all connected Non-Empty cells.
Author Yogesh
0 upvotes
Count All Number Of Paths Of A Given Matrix MEDIUM
The article discusses the problem of counting all possible number of paths from top left to bottom right in a given matrix along with its implementation in C++.
Count All Sorted Rows in a Matrix
This blog will cover the problem of counting the number of sorted rows either in increasing or decreasing order in a matrix and its time and space complexities.
Author coldz
0 upvotes
Maximum Product of 4 Adjacent Elements in a Matrix
This blog will cover the problem of finding the maximum product of 4 adjacent elements in a matrix in any direction and its time and space complexities.
Author coldz
0 upvotes
Minimum Number of Operations Required to Set All Elements of a Binary Matrix
This blog will discuss how we can solve a classical problem of BFS and one of the most asked problems in interviews, i.e., Minimum number of operations required to set all elements of a binary matrix.
Multiplication of two matrices EASY
In this article, we will discuss how to find the multiplication of two matrices.
Rotate a Matrix 90 Degrees (Without using Extra Space) EASY
In this article, we are going to rotate a given matrix by 90 degrees without using the extra space, by transposing and reversing the column of the matrix.
Rotate a Matrix by 180-degree EASY
In this article, we are going to rotate a given matrix by 180 degrees without using the extra space, by using a naive approach, i.e. by printing a reverse matrix and by swapping positions of elements of the matrix.
Rotate a Matrix Right by K Elements
This article mainly focuses on the problem Rotate a Matrix Right by K Elements. We will explain to you the approach to solving the problem.
Rotate Each Ring of Matrix Clockwise by K Elements MEDIUM
In this blog, we will solve an interesting coding problem involving spiral traversal of a matrix and rotation of the spiral traversal.
Rotate Matrix Elements EASY
In this blog, we will learn how to rotate matrix elements clockwise in different programming languages C++, Java and Python.
Interchange elements of first and last rows in matrix EASY
The reader will learn about how to interchange the elements of the first and last row in a matrix in this article.
Count Zeros in a row wise and column wise sorted matrix MEDIUM
This blog will cover the problem of counting the number of zeroes in a row-wise and column-wise sorted matrix and its time and space complexities.
Author coldz
0 upvotes
Given 1’s, 2’s, 3’s ……k’s Print them in ZigZag way MEDIUM
This blog will cover the problem of printing a given number of 1’s,2’s,3’s ….k’s in a zig-zag pattern in a 2-d matrix and its time and space complexities.
Author coldz
0 upvotes
Check if all rows of a matrix are circular rotations of each other
In this article, we will see how to check if all the rows of the given matrix are circular rotations of each other or not, in detail.
Check Diagonal Matrix and Scalar Matrix EASY
In this blog, you’ll learn some programs to check diagonal matrix and scalar matrix.
Diagonally Dominant Matrix EASY
In this article, we will explore the diagonally dominant matrix and write programs to check the diagonally dominant matrix.
Unique elements in a Matrix EASY
In this blog, you will learn about the problem of finding unique elements in a matrix
Scalar Multiplication of a matrix EASY
In this blog, we will discuss how to perform the scalar multiplication of a matrix.
Matrix Chain Multiplication
In this blog, we will discuss an important dynamic programming question, matrix chain multiplication. Dynamic programming is the key to solve this problem.
Kronecker Product of Two Matrices
This article incorporates a detailed discussion on the problem Kronecker Product of two matrices with implementation.
Author Alisha
0 upvotes
Squares of Diagonals of a Matrix
This blog explains how to print squares of diagonal elements of a matrix.
Program to Check Involutory Matrix
The reader will learn about how to check whether a matrix is an Involutory matrix or not in this article.
Program to Check Idempotent Matrix EASY
This blog focuses on the Program to Check Idempotent Matrix. We will discuss the implementation of the Idempotent Matrix in different programming languages.
Print X’th element in the spiral form of a matrix
This blog will cover a multidimensional array problem to Print X’th element in the spiral form of a matrix and its time and space complexities.
Row-wise vs Column-wise Traversal of a Matrix EASY
This blog mainly focuses on the Row-wise and Column-wise Traversal of a Matrix. We will show you row-major and column-major traversals and their differences.
Find Sum of all Elements in a Matrix except the Elements in Row and/or Column of Given Cell
In this blog, we will discuss a programming question where we have to find the sum of all the elements in the Matrix except some of the given cells in the matrix.
Swap upper diagonal elements with lower diagonal elements of matrix MEDIUM
In this blog, we will discuss a programming question in which we have to swap the elements of a matrix.
Author Harsh
0 upvotes
Magic Square (Odd Order) EASY
In this blog, we'll talk about how to make a magic square of size n programmatically. We will learn about the algorithms and step to implement the Magic Square.
Magic Square (Even order)
In this article we will talk about what magic square is and its properties and algorithm for it.
Magic Square Matrix
In this article we will try to understand whether a given matrix is magic square or not using examples.
Markov Matrix EASY
The reader will learn about the Markov matrix in this article.
Strassen’s Matrix Multiplication MEDIUM
Strassen's Matrix Multiplication is a divide-and-conquer technique used to efficiently solve matrix multiplication problems.
Author Harsh
0 upvotes
Sort the matrix row-wise and column-wise EASY
In this blog, we will discuss a program to sort the matrix row-wise and column-wise.
Kunal and Triplets
This article will discuss the solution for the problem statement “Kunal and Triplets” in which some operation on a Triplets of the given array has to be performed. Along with the solution, the article focuses on the time and space complexity of the solution.
Sparse Table Construction (SUM QRY)
In this article, we will learn how to solve range sum query using the sparse table.
Range Min Using Sparse Table
In this article, we will learn how to solve range minimum query using the sparse table.
Range GCD Query Using Sparse Table MEDIUM
This blog will learn how to solve problems based on a range query using the sparse table.
Find median of row-wise sorted matrix EASY
In this article, we will discuss how to find the median of the row-wise sorted matrix.
Minimum Operations required to make each Column and Row of the Matrix Equals HARD
This blog will cover a multidimensional array problem of finding the Minimum operations required to make each column and row of the matrix equal and its time and space complexities.
Count the number of times k appears in a matrix of size n, with matrix(i, j) = i+j.
This blog will cover a multidimensional array problem of Counting the number of times k appears in a matrix of size n, with matrix(i, j) = i+j and its time and space complexities.
Sum of the middle row and column in Matrix EASY
In this blog, you will learn about the problem of finding the sum of the middle row and column in a matrix. We will go over various approaches to solve this problem.
Sum Of The Values Of All Paths In A Grid
In this article, we will study how to find the sum of the values of all paths in a grid starting from the top left corner to the bottom right corner and moving only down or right.
Shifting matrix elements row-wise by k
This blog gives an overview of shifting matrix elements row-wise by k in different programming languages.
Finding the distinct elements common to all rows of the matrix
This blog will cover a multi-dimensional array problem to find distinct elements common to all rows of a matrix and its time and space complexities.
Implementation of Deque Using A Circular Array MEDIUM
This blog explains the concept of Deque using a circular array along with its implementation and time complexities.
Searching and Sorting in Rotated Sorted Array  | Part-2
n this blog, we discussed the method to search an element in a rotated sorted array with duplicate elements. Read the blog to learn it in detail.
Find common elements in three sorted arrays EASY
This blog will give you detailed explanation and implementation of the approach to find common elements in three sorted arrays.
Find the missing and repeating number in an array MEDIUM
In this blog, we will discuss the problem of finding the missing and repeating element in an array.
Search in a Row wise and Column wise Sorted Matrix
This blog will cover the problem of searching for an element in a sorted 2-D matrix and returning its position and its time and space complexities.
Author coldz
0 upvotes
Maximize Subarray Sum of Given Array by Adding X in the Range [L, R] for Q queries
This blog will discuss an application of Kadane’s Algorithm and one of the most asked problems in interviews, i.e., maximize subarray sum of given array by adding X in the range [L, R] for Q queries.
Aggressive Cows MEDIUM
This article explains the solution to a famous problem, “Aggressive Cows,” ranging from brute force to the most optimal approach
Book Allocation Problem MEDIUM
Find the minimum number of pages to be allocated to students so that each student gets at least one book. Let’s discuss an efficient algorithm to solve it.
Maximum triplet sum in Array
This article will brief you on finding the maximum triplet sum in Array.
Search an element in an array where difference between adjacent elements is 1 MEDIUM
In this blog, we will cover the problem of finding an element in an array where the difference between adjacent elements is 1 and discuss its time and space complexities.
Search an Element in an Unsorted Array using Minimum Number of Comparisons MEDIUM
In this blog, we will cover the problem of searching an element in an unsorted array using a minimum number of comparisons and discuss its time complexities.
Square Root using binary search EASY
In this blog, we will briefly discuss the concept of binary search and how to utilize it to find the square root of an element in log(N) time efficiently.
Count of only Repeated Element in a Sorted Array of Consecutive Elements EASY
This blog will cover the problem of the count of only repeated elements in a sorted array of consecutive elements and its time and space complexities.
Find Element in a Sorted Array whose Frequency is Greater than or Equal to n/2 MEDIUM
In this article, we are going to discuss the nested loop approach and the Boyer-Moore majority vote algorithm approach to find element in a sorted array whose frequency is greater than or equal to n/2.
Find the minimum element in a sorted and Rotated Array
This blog discusses an important interview question: Finding the minimum element in a sorted and rotated array.
Find a Fixed Point (Value equal to Index) in a Given Array EASY
In this blog, we will cover the problem of Finding a Fixed Point whose value is equal to the index in a given array and discuss its time and space complexities.
Plates Between Candles
In this blog, you will solve a medium-level Leetcode programming question named "Plates Between Candles."
Ceiling in a sorted array
 This article will brief you on finding the ceiling in a sorted array.
Binary Search in Sorted Vector of Pairs EASY
In this article, we are going to discuss binary search in sorted vector of pairs.
Find the only repetitive element between 1 to n-1 EASY
This blog will give you detailed explanation and implementation of the approach to find the only repetitive element between 1 to n-1
Find the subarray with the least average
In this article, we will find a subarray that has the least average that is a subarray with the minimum average.
Given an array of size n and a number k, find all elements that appear more than n/k times.
This current article will discuss the problem "Given an array of size n and a number k, we need to find all elements that appear more than n/k times." We will discuss this problem in different approaches.
Sort a Rotated Sorted Array
This blog is focused on methods we can use for sorting a rotated sorted array of distinct elements. Read further to learn these methods in detail.
Merge Sort Pseudocode in C, C++, Java, and Python MEDIUM
Merge Sort is a popular comparison-based sorting algorithm that follows the divide-and-conquer paradigm. Here's how it works:
Sort the matrix EASY
In this article, we will discuss how to sort the matrix.
Sort an Array in Waveform EASY
In this article, we will understand how to sort an array in waveform along with the different types of approaches to solve the problem.
Alternative Sorting EASY
In this article, we will discuss the problem of Alternative sorting along with its time complexity and auxiliary space.
Smallest Index with Equal Value
In this blog, we will discuss a Leetcode Easy problem, smallest index with equal value. This problem has been asked in the latest weekly contest organized by Leetcode.
Find The Last
In this article, we will try to solve a question on sorting algorithms that can be asked in interviews.
Sort an Array According to the Relative Order of Another Array MEDIUM
This article discusses a program for sorting an array in the order defined by another array.
Sort Elements by Frequency MEDIUM
In this article, we will learn how to sort elements by frequency along with their time complexity.
Program to find the number of misplaced elements from the index after sorting
This article discusses the approach to finding the number of misplaced elements from the index after sorting with its C++ code.
Author Spider
0 upvotes
Sort the Given Array after Sorting Each Number Individually
In this article, we will discuss how to sort the given Array after sorting each number individually.
Sort all even numbers in the Array without changing the order of odd elements
This article covers how to sort all even numbers in the array without changing the order of odd elements with examples and code in C++.
Author Spider
0 upvotes
Sort rows in ascending order followed by columns in descending
In this blog, you will learn how to sort rows in ascending order followed by columns in descending order. We will go in-depth and analyse time complexity as well.
Sorting Array Except Elements in a Subarray
This blog discusses the approach to sorting an array while taking care that a particular subarray remains untouched.
Count minimum steps to get the desired array MEDIUM
In this blog, We will see the solution to the problem count the minimum steps to get the desired array in cpp.
Minimum swaps required to bring all elements together less than or equal to a given number EASY
This blog will discuss the problem of Minimum swaps required to bring all elements together less than or equal to a given number.
Merging two unsorted arrays in sorted order
In the blog, we will discuss the problem of merging two unsorted arrays into a single sorted array.
MO’s algorithm and its applications HARD
This article incorporates information on MO's algorithm and its application in competitive programming.
How do You Move All the Zeros to the Left of the Array? EASY
This article demonstrates how you move all the zeros to the left of the array.
Greedy Algorithms in Array EASY
This blog discusses greedy algorithms in an array and mentions important problems in the domain of greedy algorithms.
Count the number of possible triangles EASY
In this blog, we will discuss different approaches to count the possible number of triangles in an array. Then we will discuss their algorithms, implementations, and complexities analysis.
All Unique Triplets that Sum up to a Given Value
This article discussed different approaches to finding all the unique triplets that sum to a given value. First, a method is discussed which uses O(n) space and the second approach is the optimization over the first approach, which does the task in O(1) space.
Sorting all array elements except one EASY
This blog discuss the sorting problem in which we sort all array elements except one.