# Category Archives: Hash

## Find subarray with given sum | Set 2 (Handles Negative Numbers)

Given an unsorted array of integers, find a subarray which adds to a given number. If there are more than one subarrays with the sum… Read More »

## Find smallest range containing elements from k lists

Given k sorted lists of integers of size n each, find the smallest range that includes at least element from each of the k lists.… Read More »

## Pair with given product | Set 1 (Find if any pair exists)

Given an array of distinct elements and a number x, find if there is a pair with a product equal to x. Examples : Input… Read More »

## Find missing elements of a range

Given an array arr[0..n-1] of distinct elements and a range [low, high], find all numbers that are in range, but not in array. The missing… Read More »

## Construct a Binary Tree from Postorder and Inorder

Given Postorder and Inorder traversals, construct the tree. Examples: Input : in[] = {2, 1, 3} post[] = {2, 3, 1} Output : Root of… Read More »

## Cuckoo Hashing – Worst case O(1) Lookup!

Background : There are three basic operations that must be supported by a hash table (or a dictionary): Lookup(key): return true if key is there… Read More »

## Common elements in all rows of a given matrix

Given an m x n matrix, find all common elements present in all rows in O(mn) time and one traversal of matrix. Example: Input: mat[4][5]… Read More »

## Implementing our Own Hash Table with Separate Chaining in Java

Every data structure has its own special characteristics for example a BST is used when quick searching of an element (in log(n)) is required. A… Read More »

## Count pairs with given sum

Given an array of integers, and a number ‘sum’, find the number of pairs of integers in the array whose sum is equal to ‘sum’.… Read More »

## Find lost element from a duplicated array

Given two arrays which are duplicates of each other except one element, that is one element from one of the array is missing, we need… Read More »

## Convert an array to reduced form | Set 1 (Simple and Hashing)

Given an array with n distinct elements, convert the given array to a form where all elements are in range from 0 to n-1. The… Read More »

## Find Recurring Sequence in a Fraction

Given a fraction, find a recurring sequence of digits if exists, otherwise, print “No recurring sequence”.Examples: Input : Numerator = 8, Denominator = 3 Output… Read More »

## Overview of Data Structures | Set 2 (Binary Tree, BST, Heap and Hash)

We have discussed Overview of Array, Linked List, Queue and Stack. In this article following Data Structures are discussed. 5. Binary Tree 6. Binary Search… Read More »

## Find the most frequent digit without using array/string

Given an integer, find the most occurring digit in it. If two or more digits occur same number of times, then return the highest of… Read More »

## Check if an array can be divided into pairs whose sum is divisible by k

Given an array of integers and a number k, write a function that returns true if given array can be divided into pairs such that… Read More »