The Wayback Machine - https://web.archive.org/web/20211007171959/https://www.geeksforgeeks.org/hard/189/
Skip to content
All Hard Articles
Given a Binary Tree, write a function that returns the size of the largest subtree which is also a Binary Search Tree (BST). If the… Read More
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The problem is not actually to perform the multiplications, but… Read More
Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1,… Read More
Given a Singly Linked List which has data members sorted in ascending order. Construct a Balanced Binary Search Tree which has same data members as… Read More
Write a function to connect all the adjacent nodes at the same level in a binary tree. Structure of the given Binary Tree node is… Read More
Ever wondered how can you design a class in C++ which can’t be inherited. Java and C# programming languages have this feature built-in. You can… Read More
In the virtual constructor idiom we have seen the way to construct an object whose type is not determined until runtime. Is it possible to create… Read More
Can we make a class constructor virtual in C++ to create polymorphic objects? No. C++ being statically typed (the purpose of RTTI is different) language, it is… Read More
Subset sum problem is to find subset of elements that are selected from a given set whose sum adds up to a given number K. We… Read More
Subset sum problem is to find subset of elements that are selected from a given set whose sum adds up to a given number K. We… Read More
The N Queen is the problem of placing N chess queens on an N×N chessboard so that no two queens attack each other. For example,… Read More
Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may… Read More
Given a team of N players. How many minimum games are required to find second best player? We can use adversary arguments based on tournament… Read More
Given an integer array of length N (an arbitrarily large number). How to count number of set bits in the array? The simple approach would be, create… Read More
Given two strings, string1 and string2, the task is to find the smallest substring in string1 containing all characters of string2 efficiently.  Examples: Attention reader! Don’t… Read More
Following questions have been asked in GATE 2011 exam. 1) A max-heap is a heap where the value of each parent is greater than or… Read More
Given below a small piece of code from an open source project, Take a step-up from those "Hello World" programs. Learn to implement data structures… Read More
Given a number x, find next number with same number of 1 bits in it’s binary representation.For example, consider x = 12, whose binary representation… Read More
What do we mean by data alignment, structure packing and padding?Predict the output of following program.Take a step-up from those "Hello World" programs. Learn to… Read More