All content related to hashing

Find the Length of the Largest Subarray with Zero Sum

Given an array X[] of n integer elements, write a program to find the length of the longest subarray with a sum equal to 0. In general, for all j > i, find **max (j - i + 1)** among all subarray with zero-sum. Note: the length of a subarray starting from index i and ending at index j = j - i + 1.

EnjoyAlgorithms

Fizz Buzz Problem

This game is played in a group, where players take turns to say the next number in a sequence, counting one at a time. If the number is divisible by 3, the player must say, “Fizz” instead of the number itself. If the number is divisible by 5, the player must say, “Buzz”. If the number is divisible by both three and five, the player has to say, “Fizz buzz”. Given a number n, write a program that outputs the string representation of numbers from 1 to n.

EnjoyAlgorithms

Count distinct elements in every window

Given array X[] of n integers, write a program to return the count of distinct numbers in all windows of size k.

EnjoyAlgorithms

Triplet with zero sum

Given an array X[] of distinct elements, write a program to find all the unique triplets in the array whose sum is equal to zero.

EnjoyAlgorithms

Check if two arrays are equal or not

Given two integer arrays X[] and Y[], write a program to check if the arrays are equal or not. Two arrays are equal if they have the same elements in any order. If there are repeated elements, then counts of repeated elements must also be the same for both arrays.

EnjoyAlgorithms

Counting Sort

The counting sort algorithm assumes that each n input element is an integer in the range 0 to k. So by using array indexing as a tool for determining relative order, counting sort can sort n numbers in O(k + n) time when k = O(n). In other words, counting sort is one of the popular linear time sorting algorithms that works in O(n) time complexity if input elements are an integer in the range 0 to k.

EnjoyAlgorithms

Introduction to Hashing

Hashing is an effcient searching technique that maps keys and values into the hash table using a hash function. Explore this blog to learn: how do we perform hash mapping in data structures? How do hash maps work? What are some popular hash functions in programming?

EnjoyAlgorithms

Longest Substring Without Repeating Characters

Write a program to find the length of the longest substring without repeating characters. Substring is the continuous sub-part of the string. The aim is to determine the maximum such subpart which has all the unique characters.

EnjoyAlgorithms

First Missing Positive

Given an array that includes both positive and negative numbers, write a program to find the first missing positive integer.

EnjoyAlgorithms

Longest Consecutive Sequence

Given an unsorted array X[] consisting of n integers, we need to write a program to find the length of the longest consecutive sequence of integers in the array. The consecutive numbers can be in any order.

EnjoyAlgorithms

Find most frequent element in an array

Given an array X[] of size n, write a program to find the most frequent element in the array, i.e. the element which occurs the most number of times. It is assumed that at least one element is repeated.

EnjoyAlgorithms

Find whether an array is a subset of another array

We are given two integer arrays X[] and Y[], write a program to check whether array Y[] is a subset of array X[] or not. An array Y is a subset of another array X if each Y element is present in X. How do you check if one array is a subset of another? Explore and Enjoy!

EnjoyAlgorithms

Majority element in an array

You are given an array X[] consisting of n elements, write a program to find majority element in an array i..e return the number which appears more than n/2 times. You may assume that the array is non-empty and the majority element always exists in the array. A majority element is an element that appears more than n/2 times, so there is at most one such element.

EnjoyAlgorithms

Check for pair in an array with a given sum

Given an array of n integers and a target number, write a program to check whether a pair sum exits in the array or not. In other words, we need to check whether pair of elements in the array sum exactly to the target value.

EnjoyAlgorithms

n Repeated element in 2n size array

In an array of size 2n, there are n+1 unique elements, and exactly one of these elements is repeated n times. Return the element repeated n times.

EnjoyAlgorithms

Our Weekly Newsletter

Subscribe to get free weekly content on data structure and algorithms, machine learning, system design, oops and math.