Maximum Distance Between two Occurrences of Same Element in Array

Suppose you are given an array with some repeated numbers. We have to find the maximum distance between the two same occurrences of a number with different index, present in an array. Example Input: array = [1, 2, 3, 6, 2, 7] Output: 3 Explanation: Because elements at array [1] …

Read moreMaximum Distance Between two Occurrences of Same Element in Array

Group Multiple Occurrence of Array Elements Ordered by first Occurrence

You are given a question in which you have given an unsorted array with multiple occurrences of numbers. The task is to group all the multiple occurrences of array elements ordered by first occurrence. Meanwhile, the order should be the same as the number comes. Example Input: [ 2, 3,4,3,1,3,2,4] …

Read moreGroup Multiple Occurrence of Array Elements Ordered by first Occurrence

Union and Intersection of two Linked Lists

Given two linked lists, create another two linked lists to get union and intersection of the elements of existing lists. Example Input: List1: 5 → 9 → 10 → 12 → 14 List2: 3 → 5 → 9 → 14 → 21 Output: Intersection_list: 14 → 9 → 5 Union_list:   …

Read moreUnion and Intersection of two Linked Lists

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

Suppose, you have an integer array. The problem statement asks to find out the maximum difference between the frequency of any two distinct elements of a given array, but the element with the greater frequency should also be greater in value than the other integer. Example Input: arr[] = {2,4,4,4,3,2} …

Read moreMaximum difference between frequency of two elements such that element having greater frequency is also greater

Longest Subarray Having Count of 1s One More than Count of 0s

We have given an array of integers. An array contains 1’s and 0’s only. The problem statement asks to find out the length of the longest Sub-Array which having the quantity of 1’s digit is just one more than the count of 0’s in a sub-array. Example Input: arr[] = …

Read moreLongest Subarray Having Count of 1s One More than Count of 0s

Maximum Array from Two given Arrays Keeping Order Same

Suppose we have two integers array of same size n. Both of the arrays can contain common numbers as well. The problem statement asks to form the resultant array that contains the ‘n’ maximum values from both of the arrays. The first array should be prioritized (elements of the first …

Read moreMaximum Array from Two given Arrays Keeping Order Same

Find Smallest Range Containing Elements from k Lists

In the problem “Find the smallest range containing elements from k lists” we have given K lists which are sorted and of the same size N. It asks to determine the smallest range that contains at least element(s) from each of the K lists. If there is more than one …

Read moreFind Smallest Range Containing Elements from k Lists