## Print n x n spiral matrix using O(1) extra space

Given a number n, print a n x n spiral matrix (of numbers from 1 to n x n) in clockwise direction using O(1) space.… Read More »

## Print a pattern without using any loop

Given a number n, print following a pattern without using any loop. Examples : Input: n = 16 Output: 16, 11, 6, 1, -4, 1,… Read More »

## Print string of odd length in ‘X’ format

Given a string of odd length, print the string X format. Examples : Input: 12345 Output: 1 5 2 4 3 2 4 1 5… Read More »

## Look-and-Say Sequence

Find the n’th term in Look-and-say (Or Count and Say) Sequence. The look-and-say sequence is the sequence of below integers: 1, 11, 21, 1211, 111221,… Read More »

## C Program to print Floyd’s triangle

Floyd’s triangle is a triangle with first natural numbers. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Recommended:… Read More »

## Zigzag (or diagonal) traversal of Matrix

Given a 2D matrix, print all elements of the given matrix in diagonal order. For example, consider the following 5 X 4 input matrix. 1… Read More »

## Pascal’s Triangle

Pascal’s triangle is a triangular array of the binomial coefficients. Write a function that takes an integer value n as input and prints first n… Read More »

## Print a given matrix in spiral form

Given a 2D array, print it in spiral form. See the following examples. Examples: Input: 1 2 3 4 5 6 7 8 9 10… Read More »