Array Problems

Interview Questions On Array

Inserting Elements into an Array

Data structure questions with story like explanation.

Are you learning C++ or Java and struggling with inserting elements into an array? If so, this blog post is for you! In this post, we'll walk through a program that inserts a new value into an array at a specified index.

For example:
If we have an array {1, 2, 3, 4, 5} and we want to insert the value 6 at index 2, the resulting array would be {1, 2, 6, 3, 4, 5}. Please make sure to ask the user for the index and value to be inserted.

Read More

Move all Zeros to the end of the array

Data structure questions with story like explanation.

In this article we will learn how to solve the most asked coding interview problem: “Move all Zeros to the end of the array” Problem Statement:

You are given an array of integers, your task is to move all the zeros in the array to the end of the array and move non-negative integers to the front by maintaining their order. Examples:

Example 1: Input: 1 ,0 ,2 ,3 ,0 ,4 ,0 ,1
Output:
1 ,2 ,3 ,4 ,1 ,0 ,0 ,0
Explanation:
All the zeros are moved to the end and non-negative integers are moved to front by maintaining order

Read More

Left Rotate the Array by One

Data structure questions with story like explanation.

In this article we will learn how to solve the most asked coding interview problem: “Left Rotate the Array by One”

Problem Statement: You are given an array of integers, your task is to rotate the given array towards left by one. Examples:

Example 1:
Input: N = 5, array[] = {1,2,3,4,5}
Output: 2,3,4,5,1
Explanation:
Since all the elements in array will be shifted toward left by one so '2' will now become the first index and and '1' which was present at first index will be shifted at last.

Read More