## Find Common Elements in Three Sorted Arrays – Java Code

Write a java program to find common elements in three sorted arrays. Given three sorted arrays, write a code to print intersection of three sorted arrays.

For example –

arr1 = {1, 5, 10, 20, 40, 80};
arr2 = {6, 7, 20, 80, 100};
arr3 = {3, 4, 15, 20, 30, 70, 80, 120};

Output : {20, 80}

20 and 80 is the common element between three sorted arrays.

## Segregate 0s and 1s in an Array – Java Code

Segregate 0s and 1s in an Array. Given an array of 0s and 1s in random order. Write a java program to segregate 0’s on left side and 1’s on right side of the array.

Subscribe Our Tutorials

For example –

Input array = [0, 1, 0, 1, 0, 0, 1]
Output array = [0, 0, 0, 0, 1, 1, 1]

## Insertion Sort Program in Java

Insertion Sort Program in Java. Write a java program to sort an unsorted array using insertion sort.

In this tutorial, We are going to cover following points.

• How insertion sort works?
• Insertion sort program in java.
• Video tutorial which explain insertion sort algorithm.

Let’s say we have an unsorted array and we want to sort this array using insertion sort. Let’s first understand how insertion sort works?

Input : {5, 4, 2, 9, 1}

Output : {1, 2, 4, 5, 9}

## Find Largest Sum Contiguous Subarray – Kadane’s algorithm

Write a program to find largest sum contiguous subarray. Given an array of N elements, find the maximum possible sum of a contiguous subarray. An array can contain both positive and negative values.

For example –

Let’s take an array whose values are { 1, 2, -5, 4, 3, 8 , 5 }

The maximum sum of a subarray in this array is 20.  And the subarray is (4, 3, 8, 5).

## Find Common Elements in Two Arrays – Intersection of two Arrays

Write a c program to find common elements in two arrays. Given two positive integer arrays arr1 and arr2 of lengths len1 and len2 we have to write a c code to find intersection of these two arrays. Both the arrays are sorted.

Let’s assume we have following two sorted arrays arr1 and arr2.

int arr1[] = {2,  3,  4,  5,  6};
int arr2[] = {4,  6,  7,  8,  9};

So the common elements in these two arrays is 4 and 6.

## Program to Search an Element in an Array

Write a program to search an element in an array. Given a sorted array, how do you search an element in an array. Think for a moment how do you solve this problem.

You can use multiple approaches to find the solution of this problem. But try to solve this problem in minimum time complexity.

## Find the Second Largest Number in an Array

Write a program to find the second largest number in an array. Given an unsorted array, we have to write a code to find the second largest number in an array. Also, we need to focus on time complexity. As the time complexity of an algorithm is very important in terms of an interview.

For example – Let’s take an array.

Input – arr[] = { 4, 1, 5, 2, 8, 0, 3, 55}

Output – 8

The second largest element in this array is 8.  Think for a moment, how do you find the second largest number in an array?  There are multiple ways to solve this problem. Which approach you prefer and why?

In this tutorial, we cover following things –

• How to find the second largest number in an array using sorting.
• C program to find the second largest number in an array.
• C++ program to find the second largest number in an array.

## C Program to Find Missing number in Array

Write a c program to find missing number in array. Given an array of numbers from 1 to n. The array is sorted. One number is missing from an array. You have to write a c code to find the missing number from an array. Also ,there is no duplicates in an array. This type of questions is generally asked in technical interviews

## C Program to Reverse a String using Stack, Pointers, Recursion & Swap

Write a c program to reverse a string without using strrev function. Given an input string, we have to write a method to reverse a string. In c, you can simply reverse a string using an inbuilt strrev() function. But we don’t have to use this method.

Think how do you solve this problem. In this tutorial, we write a c code to reverse a string using stack, pointers, recursion, loop.

## Stack Program in C using an Array – Stack Tutorial Part – I

Write a stack program in C using an array. Implement a stack data structure using an Array. In this tutorial, You are going to learn about stack data structure and it’s implementation in C using an array.

C Program to Implement a Stack using Linked List

## What is a Stack Data Structure?

A Stack is a Data Structure, in which insertion and deletion operations are allowed only at one end. It worked on LIFO (Last In First Out) Principle. In LIFO, an element which inserted last must be the first element to be removed.