Print all diagonals of a matrix in alternate order

Given a square matrix of order N*N, write code to print all the elements in the order of their diagonal in alternate forward and backward […]

Compare to strings given as linked list

In C language, string library has a function strcmp that takes two arguments and return -1, 0 or 1 depending on whether first string is […]

Find minimum and maximum value in a tree

Given a Binary tree (not BST), write code to find the minimum and maximum value in the tree. For example, if the tree is as […]

Prisoners and the lightbulb puzzle

There are 10 prisoners are in 10 different cells of a prison. There is no way in which they can communicate with each other. Each night, […]

Code to evaluate a postfix expression

Given an expression in postfix notation, write code to evalute a mathematical expression given in postfix notation. For Example: Input: 4 2 3 + * […]

Code to convert In-Fix to postfix notation

Given an arithmetic expression in in-fix notation. Write code to convert that algorithm in corresponding post-fix notation. For example: Infix Postfix ------ -------- a+b ab+ […]

Logic Puzzle: Inverting the glasses

Four glasses are placed on the four corners of a square rotating table. Each glass is either upright (up) or upside-down (down). You have to […]

Interview Puzzle: Heaven or Hell

You are standing before two closed doors. One of the doors leads to heaven and the other one leads to hell. Two watchmen are standing, one in front […]

Upstream-Downstream relative speed question

A person rides a cycle at a constant speed. When he drives in the direction of the wind, he is able to go 35 km in 5 […]

Minimum number of platform required for a railway station

Given arrival and departure times of all trains for a particular railway station, write code to find the minimum number of platforms required on that […]