Problem Statement: You are given an array that has elements of arithmetic progression in order. One element is missing, you need to find that Example Input: arr = {2, 4, 6, 10, 12, 14} Output: 8 Solution This problem can be solved in number of …
Problem Statement: you are given an integer, you need to return the number of trailing zeros in n!. Example Input: n = 5 Output: 1 Because the factorial of 5 is 120 which has one trailing 0. Solution We know that, to get a trailing zeros, …
Problem Statement: You are given 2 arrays that are sorted. You need to find the k’th element if the two arrays are sorted and merged. Example Array 1 - 1 3 5 Array 2 - 2 4 6 k = 3 Sorted array = {1, …
Problem Statement: You are given an unsorted array. You need to find the first and second smallest element in that unsorted array. You need to do it with minimum comparisons. Example Input: {5, 3, 1, 6, 7, 9, 10} Output: The smallest element is 1 …
Problem Statement: You are given an array of distinct elements. You need to find the minimum number of swaps required to sort the array. Example Input : {4, 3, 2, 1} Output : 2 We need to swap index 0 with 3 and 1 with 2 …
Problem Statement: You are given a array. You have to sort the integers in ascending order by the number of 1’s in their binary format. Example Input: arr = {1, 2, 3, 4, 5, 6}; Output: 3 5 6 1 2 4 Explanation: 3 - …
Problem Statement: You are given an array, you need to return an array of the product such that the prod is equal to the product of all the element of arr except arr. Example Input = {1, 2, 3, 4, 5} O/p = {120, 60, …
Problem Statement: You are given an array and you need to print all the sub array with the sum 0. Example Input: Subarrays with zero-sum are { -3, -1, 0, 4 } { 0 } Solution The solution is very simple. We will take …
Problem Statement: You are given two sorted arrays x and y of size m and n, You need to merge elements of array x to y by maintaining sorted order. Example Input: arr1 = {20}; arr2 = {5, 6}; Output: arr1 = {5} arr2 = …