Problem Statement: Given an unsorted array, check if it is palindrome array or not. Example: arr = {1, 2, 0, 2, 1} Output: Palindrome Solution: The solution is very simple, below are the steps to be follow: 1. We take 2 pointer, first pointer will …
Problem Statement: You are given 2 sorted arrays of same size. You need to obtain the median (middle) of the array. But first, what is a median? Median is an element separating higher half of the data from a lower half. It can be thought of …
Problem Statement: You are given an array, you need to find the minimum number of merge operations to be performed to make the array as a palindrome. You can only merge 2 adjacent elements. Example: arr = {1, 4, 5, 1} Output: 1 Here if …
Problem Statement: You are given an array and a number K. You need to find the minimum number of swaps to bring all the numbers less than “k” together. Example: arr = {2, 1, 5, 6, 3}, k = 3 Output: 1 To bring together, swap …
Problem Statement: Given an array and 2 values , you need to create a partition such that: 1. Elements of the first partition will be lesser than “a” 2. Next partition such that elements lies within the given range will be in this partition 3. Numbers …
Problem Statement: Given an unsorted array, you need to find 3 elements whose sum is the minimum. Example: arr = {-1, 2, 3, -2}; Output: -1 The elements are: -1, -2, 2 The solution in very simple, take 3 variables that will hold minimum, second …
Problem Statement: Given an unsorted array and a key, you need to find 3 elements in the array that is equal to the key. Example: arr = {2, 1, 10, 4, 5}, sum = 9; Output: 4, 5 Solution This problem can be solved with …
Problem Statement: Given 2 arrays, check if arr2 is a subset of arr1. Consider all the elements are distinct and both the arrays are not sorted. We can solve this be number of different ways. Some of the ways that are discussed are: 1. Use 2 …
Problem Statement: You are given with 2 sorted arrays, you need to merge the array in-place. You may assume that the first array will have enough space to accommodate all the array elements. Example: Input: arr1 = arr2 = Output: According to the question, we …