## 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.

## Get Minimum Element from Stack in O(1)

Design a stack to get minimum element from stack in O(1) (constant time).

For example : Suppose, If we push following elements in a stack.

9  ==> Top
1
2
3

Subscribe Our Tutorials

Then if we call getMin() method, It will return 1 in O(1) (constant time). In a stack, Element which pushed last in the stack is the first element to be popped out. Think for a moment how we can solve this problem.

## How to Check if a Number is a Power of 2

How to check if a number is a power of 2.  To understand this question, let’s take some example.

Example –

Input – 16   – 16 is a power of 2 (2^4).

Input – 15 – 15 is not a power of 2.

Input – 32- 32 is a power of 2 (2^5).

We can use multiple approaches to check whether a number is a power of 2 or not.

## How to Convert Decimal to Binary Number – Java Code

Given a  decimal  number, Write a java program to convert decimal to binary number.

For example :

Input : 4 ,   Output : 100

Input : 5 ,    Output : 101

Input : 10 ,    Output : 1010

## Find Second Smallest Number in an Array : Java Code

Write a java program to find second smallest number in an array. Given an input array, write a java code to print second smallest number of an array.

For example :

arr = {-1, 7, 1, 34, 18}

The second smallest number in this array is 1.

## Sorting Algorithms and their Time Complexities

In this tutorial, We are going to learn various sorting algorithms and their time complexities. Before comparing the time complexity of various sorting algorithms, let’s first understand what’s the time complexity of an algorithm and why it is important.

## PHP Program to Print Prime Numbers between 1 to N using Sieve Algorithm

Write a php program to print prime numbers between 1 to N. In this tutorial, we are going to use Sieve of Eratosthenes algorithm to print prime numbers between 1 to N.

## Java Program to Check Armstrong Number

Write a java program to check Armstrong number. In this program, we are going to write a java code which checks whether a number is Armstrong or not.

Let’s first understand what is Armstrong number?

## Find GCD of Two Numbers using Recursion – Java Code

Write a Java program to find GCD of two numbers using Recursion. Given two input integers, we have to write a code to find GCD of two numbers using recursion. For this program, I assume you are familiar with the concept of recursion. If you don’t know about recursion then check my previous post on recursion vs iteration.