Check if a pair with given product exists in Linked list
Given a linked list, and a product K. The task is to check if there exist two numbers in the linked list whose product is equal to the given number K. If there exist two numbers, print them. If there are multiple answers, print any of them....
read more
Pair with given sum in matrix
Given a NxM matrix and a sum S. The task is to check if a pair with given Sum exists in the matrix or not....
read more
Find the only element that appears b times
Given an array where every element occurs ‘a’ times, except one element which occurs b (a>b) times. Find the element that occurs b times....
read more
Minimum swaps of same indexed elements required to obtain a Majority Element in one of the arrays
Given two arrays arr[] and brr[] of length N, the task is to find the minimum number of swaps of the same indexed elements required such an element occurs at least half of the indices in the array arr[], i.e. Majority element. If it is not possible to obtain such an arrangement, then print “-1”....
read more
C# | Intersection of two HashSets
A HashSet is an unordered collection of the unique elements. It is found in System.Collections.Generic namespace. It is used in a situation where we want to prevent duplicates from being inserted in the collection. As far as performance is concerned, it is better in comparison to the list. HashSet.IntersectWith(IEnumerable) Method is used to modify the current HashSet object to contain only elements that are present in that object and in the specified collection....
read more
Count elements of same value placed at same indices of two given arrays
Given two arrays A[] and B[] of N unique elements, the task is to find the maximum number of matched elements from the two given arrays....
read more
WeakHashMap get() Method in Java
The java.util.WeakHashMap.get() method of WeakHashMap class is used to retrieve or fetch the value mapped by a particular key mentioned in the parameter. It returns NULL when the map contains no such mapping for the key....
read more
Minimize cost to sort an Array by swapping any pair of element (X, Y) with cost as (X + Y)
Given an array arr[] consisting of N integers, the task is to find the minimum cost to sort the given array arr[] in ascending order by swapping any pair of elements (X, Y) such that the cost of swapping is (X + Y)....
read more
Max count of N using digits of M such that 2 and 5, and, 6 and 9 can be treated as same respectively
Given an integer N, and the string integer M, the task is to find the total count to make N by using the digits of string M. Also, digit 2 can be treated as digit 5, and digit 6 can be treated as digit 9 and vice versa and each digit from the string M can be used at most once....
read more
Divide array in two maximum equal length arrays of similar and dissimilar elements
Given an array arr of natural numbers up to n, find the maximum size for which array arr can be divided into two equal-sized arrays, such that the first array contains all same elements while the second array contains all distinct elements.Examples:...
read more
Java Program to Check Strings Anagram Using HashMap
Java Program to check whether two given strings are anagrams of each other or not using HashMap....
read more
Partition array into minimum number of equal length subsets consisting of a single distinct value
Given an array arr[] of size N, the task is to print the minimum count of equal length subsets the array can be partitioned into such that each subset contains only a single distinct element...
read more