## Sort Array by Increasing Frequency Leetcode Solution

Problem Statement Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order. Example nums = [1,1,2,2,2,3] [3,1,1,2,2,2] Explanation: ‘3’ has a frequency of 1, ‘1’ has a frequency of …

## Check If a String Can Break Another String Leetcode Solution

Problem Statement In this problem we are given two strings s1 and s2 with the same size. Check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa. A string x can break string y (both …

## Increasing Decreasing String Leetcode Solution

The problem Increasing Decreasing String Leetcode Solution states that we are given a string as input. We need to modify the input. Or as the question states, we need to sort it. The term sort here does not necessarily mean simply sorting the characters. We will sort the string in …

## Intersection of Two Arrays II Leetcode Solution

Problem Statement In this problem two arrays are given and we have to find out the intersection of this two arrays and return the resultant array. Each element in the result should appear as many times as it shows in both arrays. The result can be in any order. Example …

## Relative Ranks Leetcode Solution

The problem Relative Ranks Leetcode Solution asks us to return a vector or an array of strings representing the relative ranks. We are provided with an array that represents the score obtained by athletes. Then we use the given score array to assign the ranks. There is a small change …

## Relative Sort Array Leetcode Solution

In this problem, we are given two arrays of positive integers. All elements of the second array are distinct and are present in the first array. However, the first array can contain duplicate elements or elements that are not in the second array. We need to sort the first array …

## Sort Integers by The Number of 1 Bit Leetcode Solution

Problem statement In the problem ” Sort Integers by The Number of 1 Bit,” we are given an array arr. Our task is to sort the elements in the array according to the number of 1 bit in the binary representation of the number in ascending order. If two or …

## Sort Array By Parity II Leetcode Solution

Problem statement In the problem ” Sort Array By Parity II,” we are given a parity array where all the elements are positive integers. The array contains an even number of elements. The array contains an equal number of even and odd elements. Our task is to rearrange the elements …

## Count pair with Given Sum

In problem “count pair with given sum” we have given an integer array[] and another number say ‘sum’, you have to determine whether any of the two elements in a given array has a sum equal to “sum”. Example Input: arr []={1,3,4,6,7} and sum = 9. Output: “ Elements found …

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