Given a linked list, swap its k’th node from beginning with its k’th node from end. The swapping should be done in such a way that only links between the nodes are exchanged, and no data is swapped.
In this post, we will see how to sort N2 numbers in increasing order using a N x N Young tableau in O(N3) time.
A M x N Young tableau is an M x N matrix such that the entries of each row are in sorted order from left to right and the entries of each column are in sorted order from top to bottom. Some of the entries of a Young tableau may be infinity, which indicates an …
Given a directed graph and two vertices (say source and destination vertex), determine if the destination vertex is reachable from the source vertex or not. If the path exists from the source vertex to the destination vertex, print it.
Given a list of jobs where each job has a start and finish time, and also has profit associated with it, find maximum profit subset of non-overlapping jobs.
Given a binary tree, calculate the difference between sum of all nodes present at odd levels and sum of all nodes present at even level.
Given a set of rectangular 3D boxes, create a stack of boxes which is as tall as possible. A box can be placed on top of another box if the dimensions of the 2D base of the lower box are each strictly larger than those of the 2D base of the higher box. Multiple instances …
Given a binary matrix, find the largest square sub-matrix which is surrounded by all 1’s.
Given a binary tree, print its nodes in vertical order. Assume that the left and right child of a node makes 45 degree angle with the parent.
Given a binary tree, write an efficient algorithm to link nodes at the same level in the form of a linked list like structure.
In this post, we will implement Treap Data Structure and perform basic operations like insert, search and delete on it.
In this post, we will see how to implement a queue using stack data structure in C++ and Java. In other words, design a queue that supports enqueue and dequeue operations using standard push and pop operations of the stack.