## 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:   …

## Compute nCr % p

Problem Statement The problem “Compute nCr % p” states that you are required to find binomial coefficient modulo p. So you first must know about the binomial coefficient. We have already discussed that in a previous post. You can check that here. Example n = 5, r = 2, p …

## Smallest Element Repeated Exactly K Times

We are given an array A[] on size n. We have to find the smallest element that is repeated exactly k times in the array. Example Input A[]= {1, 2 ,2 ,5 ,5 ,2 ,5} K=3 Output Smallest element with frequency K is: 2 Approach 1: Brute force Main idea …

## First non Repeating Element

We are given an array A. We have to find the first non repeating element in the array. Example Input: A[]={2,1,2,1,3,4} Output: First non-repeating element is: 3 Because 1, 2 is not the answer because they are repeating and 4 is not the answer because we have to find the …

Translate »