## Program to find amount of water in a given glass

There are some glasses with equal capacity as 1 litre. The glasses are kept as follows: 1 2 3 4 5 6 7 8 9… Read More »

## Implement Stack using Queues

The problem is opposite of this post. We are given a Queue data structure that supports standard operations like enqueue() and dequeue(). We need to… Read More »

## Find the number of islands | Set 1 (Using DFS)

Given a boolean 2D matrix, find the number of islands. A group of connected 1s forms an island. For example, the below matrix contains 5… Read More »

## Find the largest BST subtree in a given Binary Tree | Set 1

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 »

## Trie | (Insert and Search)

Trie is an efficient information reTrieval data structure. Using Trie, search complexities can be brought to optimal limit (key length). If we store keys in… Read More »

## Print a given matrix in spiral form

Given a 2D array, print it in spiral form. See the following examples. Examples: Input: 1 2 3 4 5 6 7 8 9 10… Read More »

## A Product Array Puzzle

Given an array arr[] of n integers, construct a Product Array prod[] (of same size) such that prod[i] is equal to the product of all… Read More »

## Intersection of two Sorted Linked Lists

Given two lists sorted in increasing order, create and return a new list representing the intersection of the two lists. The new list should be… Read More »

## Queue using Stacks

The problem is opposite of this post. We are given a stack data structure with push and pop operations, the task is to implement a… Read More »

## Level Order Tree Traversal

Level order traversal of a tree is breadth first traversal for the tree. Level order traversal of the above tree is 1 2 3 4… Read More »

## Write a function to get the intersection point of two Linked Lists

There are two singly linked lists in a system. By some programming error, the end node of one of the linked list got linked to… Read More »

## Median of two sorted arrays of same size

There are 2 sorted arrays A and B of size n each. Write an algorithm to find the median of the array obtained after merging… Read More »

## Given a string, find its first non-repeating character

Given a string, find the first non-repeating character in it. For example, if the input string is “GeeksforGeeks”, then output should be ‘f’ and if… Read More »

## Search an element in a sorted and rotated array

An element in a sorted array can be found in O(log n) time via binary search. But suppose we rotate an ascending order sorted array… Read More »

## Largest Sum Contiguous Subarray

Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum. Recommended: Please solve… Read More »