Factorial of Number using Recursion in Java

Find Factorial of Number. OR
Java Program to Find Factorial of Number. OR
Recursive Program to find Factorial of Number.


A factorial is a function that multiplies a number by every number below it.

Factorial of 5
5! = 5 * 4 * 3 * 2 * 1 = 120.

Factorial of 3
3! = 3 * 2 * 1 = 120.

Note: The value of 0! is 1

Below you can get Factorial of number till 20.

Print Matrix Diagonally OR Diagonal order of Matrix.

Print Matrix Diagonally. OR
Loop diagonally through two dimensional array. OR
Traverse an array diagonally. OR
Print elements of Matrix in Diagonal order.


Given a Matrix / 2D array, Print all elements of Matrix in Diagonal order. Lets understand Diagonal order of Matrix graphically.

Find a Saddle point in Matrix

Find Saddle point in a matrix


Given a matrix of n x n size, Find saddle point of matrix.

What is Saddle point of Matrix?

Element is said to be Saddle point of Matrix if it is both a minimum of its row and a maximum of its column or vice versa.

A matrix may have 1 or 2 saddle points or may not have a saddle point.
Lets understand what will be input and expected output with the help of an example.


Print nodes at K distance from Leaf node in Binary tree.

Print nodes at K distance from Leaf in binary tree. OR
Print all nodes that are at distance k from a leaf node.


Given a Binary Tree, Print all Nodes that are at K distance from leaf node in Binary Tree. Lets understand what will be input and expected output with the help of an example.


If k = 1. It means we need to print all nodes that are at distance 1 from Leaf node.

In Case 2, we have 4 leaf nodes (Node 1, Node 10, Node 5, Node7).
Node at distance K that is Node at distance 1 from leaf Node 1 is Node 2 (Print 2)
Node at distance K that is Node at distance 1 from leaf Node 10 is Node 9 (Print 9)
Node at distance K that is Node at distance 1 from leaf Node 5 is Node 6 (Print 6)
Node at distance K that is Node at distance 1 from leaf Node 7 is Node 6 (6 already printed, ignore)

Print Nodes at K distance from Root in Binary Tree

Print nodes at K distance from root in binary tree. OR
Print nodes at Level K.


Given a Binary Tree, Print all Nodes that are at K distance from root node in Binary Tree. We can also think of this question as Print all nodes that belong to Level K.
 
Lets understand what will be input and expected output with the help of an example.
 

If k = 2. It means we need to print all nodes that are at distance 2 from Root node.
It also means we need to print all nodes at Level 2, because all Nodes of Level 2 will be at same distance from Root Node.

Rotate matrix by 90 degree

Rotate matrix by 90 degree OR
Turn an 2D array by 90 degree OR

Rotate a two dimensional array OR
Given N*M matrix, rotate it by 90 degree to left and right.

Given N*M Matrix, Rotate it by 90 degrees.
 
Lets understand the problem statement graphically and it will be more clear,