# Category Archives: Hash

## Find the first repeated character in a string

Given a string, find the first repeated character in it. We need to find the character that occurs more than once and whose index of… Read More »

## How to store a password in database?

Most of the web applications require their users to authenticate themselves by asking them username and password. They compare the user supplied credentials with the… Read More »

## Recaman’s sequence

Given an integer n. Print first n elements of Recaman’s sequence. Examples: Input : n = 6 Output : 0, 1, 3, 6, 2, 7… Read More »

## Find sum of non-repeating (distinct) elements in an array

Given an integer array with repeated elements, the task is to find sum of all distinct elements in array. Examples: Input : arr[] = {12,… Read More »

## Find all pairs (a,b) and (c,d) in array which satisfy ab = cd

Given an array of distinct integers, the task is to find two pairs (a, b) and (c, d) such that ab = cd, where a,… Read More »

## Group words with same set of characters

Given a list of words with lower cases. Implement a function to find all Words that have the same unique character set . Example: Input:… Read More »

## Given two unsorted arrays, find all pairs whose sum is x

Given two unsorted arrays of distinct elements, the task is to find all pairs from both arrays whose sum is equal to x. Examples: Input… Read More »

## Check if two arrays are equal or not

Given two given arrays of equal length, the task is to find if given arrays are equal or not. Two arrays are said to be… Read More »

## Find all triplets with zero sum

Given an array of distinct elements. The task is to find triplets in array whose sum is zero. Examples: Input : arr[] = {0, -1,… Read More »

## Range Queries for Frequencies of array elements

Given an array of n non-negative integers. The task is to find frequency of a particular element in the arbitrary range of array[]. The range… Read More »

## Maximum difference between frequency of two elements such that element having greater frequency is also greater

Given an array of n positive integers with many repeating elements. The task is to find maximum difference between the frequency of any two different… Read More »

## Make two sets disjoint by removing minimum elements

Given two sets of integers as two arrays of size m and n. Find count of minimum numbers that should be removed from the sets… Read More »

## Count of index pairs with equal elements in an array

Given an array of n elements. The task is to count the total number of indices (i, j) such that arr[i] = arr[j] and i… Read More »

## Print a Binary Tree in Vertical Order | Set 3 (Using Level Order Traversal)

Given a binary tree, print it vertically. The following example illustrates vertical order traversal. 1 / \ 2 3 / \ / \ 4 5… Read More »

## Pairs of Amicable Numbers

Given an array of integers, print the number of pairs in the array that form an amicable pair. Two numbers are amicable if the first… Read More »