# Category - Hashing

Hashing

## Java Programming – Design a data structure that supports insert, delete, search and getRandom in constant time

The idea is to use a resizable array (ArrayList in Java, vector in C) together with hashing. Resizable arrays support insert in Θ(1)

Hashing

## Java Programming – Count distinct elements in every window of size k

An Efficient Solution is to use the count of previous window, while sliding the window. The idea is to create a hash map that stores elements.

Hashing

## C++ Programming – Count distinct elements in every window of size k

An Efficient Solution is to use the count of previous window, while sliding the window. The idea is to create a hash map that stores elements.

Hashing

## Python Programming – Longest Consecutive Subsequence

One Solution is to first sort the array and find the longest subarray with consecutive elements. Time complexity of this solution is O(nLogn).

Hashing

## Java Programming – Longest Consecutive Subsequence

One Solution is to first sort the array and find the longest subarray with consecutive elements. Time complexity of this solution is O(nLogn).

Hashing

## C++ Programming – Longest Consecutive Subsequence

One Solution is to first sort the array and find the longest subarray with consecutive elements. Time complexity of this solution is O(nLogn).

Hashing

## C Programming – Longest Consecutive Subsequence

One Solution is to first sort the array and find the longest subarray with consecutive elements. Time complexity of this solution is O(nLogn).

## C++ Programming – 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 sum.

## Java Programming – Find number of Employees Under every Employee

A trick in step 2.b is to use memorization ( Dynamic programming ) while finding number of employees under a manager so that we don’t need to find number.

Hashing

## C++ Programming – Find Itinerary from a given list of tickets

We can also use hashing to avoid building a graph - Hashing - The idea is to first find the starting point. A starting point would never be on ‘to’ side

X