Given two four digit prime numbers, suppose 1033 and 8179, we need to find the shortest path from 1033 to 8179 by altering only single digit at a time such that every...

Share

Given a Directed Acyclic Graph (DAG), find Topological Sort of the graph.
Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such t...

Share

Given an array of n integers. The task is to find the first element that occurs k number of times. If no element occurs k times the print -1. The distribution of inte...

Share

Given an array of size n, the goal is to find out the smallest number that is repeated exactly ‘k’ times where k > 0?
And
Examples:
Input : a[] = {2...

Share

Design a data structure that supports following operations in Θ(1) time.
insert(x): Inserts an item x to the data structure if not already present.
remove(x): R...

Share

Consider the following algorithm for building a Heap of an input array A.
BUILD-HEAP(A)
heapsize := size(A);
for i := floor(heapsize/2) downto 1
...

Share

Given a singly linked list and a key, count number of occurrences of given key in linked list. For example, if given linked list is 1->2->1->2->1->3-&...

Share

Given a matrix of size N*M, and a number K. We have to rotate the matrix K times to the right side.
Examples:
Input : N = 3, M = 3, K = 2
12 23 34
...

Share

Given a matrix of dimension m*n where each cell in the matrix can have values 0, 1 or 2 which has the following meaning:
0: Empty cell
1: Cells have fresh oranges
...

Share

Question: Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() whi...

Share