Given a string consisting of symbols consisting (, {, [. You have to check whether these symbols are balanced or not.

Example :

(a+b)-(c+d) is balanced .

((a+b) is not balanced .

Algorithm

Create a stack.

While (the end of character i.e ‘\0’ is not reached){

If the character read is not a symbol to be balanced, ignore it.

If it is an opening symbol i.e (, {, [, the push it into the stack.

If it is a closing symbol ), }. ] then pop the elements ( if the stack is empty return an error ) unless the same opening symbol is encountered else report an error.

}

3. At the end, the stack must be empty, else report an error.

Suppose you have two linked list a1->a2->……am and b1->b2->…..bn. if m>n then make it a1->b1->a2->b2->…..am->bm…->bn else a1->b1->a2->b2->…….am->bn->….->an.

Given a linked list , suppose the length of the node is n and for a given k you have to find last node such that n % k == 0, modular node.n is not known.

Given a linked list which consists of even and odd numbers, your task is to move even numbers to the beginning of the linked list and the odd numbers proceed after that.

There are N greek soldiers are in a circle who are surrounded by roman soldiers. So they decide to kill each other starting with 1 each neighboring soldier kills the Mth soldier, until only one is left.And josephus doesn’t want to die so you need tell him the position he needs to be in ( josephus circle ).