Narendra Kumar has Published 191 Articles

Minimum operation to make all elements equal in array in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 05:56:20

2K+ Views

Problem statementGiven an array with n positive integers. We need to find the minimum number of operation to make all elements equal. We can perform addition, multiplication, subtraction or division with any element on an array element.ExampleIf input array is = {1, 2, 3, 4} then we require minimum 3 ... Read More

Minimum operations of given type to make all elements of a matrix equal in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 05:51:06

332 Views

Problem statementGiven an integer K and a matrix of M x N, the task is to find the minimum number of operations required to make all the elements of the matrix equal. In a single operation, K can be added to or subtracted from any element of the matrix.ExampleIf input ... Read More

Minimum operations required to make all the array elements equal in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 05:32:38

2K+ Views

Problem statementGiven an array with n positive integers. We need to find the minimum number of operation to make all elements equal. We can perform addition, multiplication, subtraction or division with any element on an array element.ExampleIf input array is = {1, 2, 3, 4} then we require minimum 3 ... Read More

Minimum operations required to remove an array in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 05:28:24

218 Views

DescriptionGiven an array of N integers where N is an even number. There are two kinds of operations allowed on the array.Increase the value of any element of an array by 1.If two adjacent elements in the array are consecutive prime number, delete both the element.The task is to find ... Read More

Max sum of M non-overlapping subarrays of size K in C++

Narendra Kumar

Narendra Kumar

Updated on 20-Dec-2019 10:39:21

285 Views

Problem statementGiven an array and two numbers M and K. We need to find sum of max M subarrays of size K (non-overlapping) in the array. (Order of array remains unchanged). K is the size of subarrays and M is the count of subarray. It may be assumed that size ... Read More

Missing Permutations in a list in C++

Narendra Kumar

Narendra Kumar

Updated on 20-Dec-2019 10:34:29

124 Views

Problem statementGiven a list of permutations of any word. Find the missing permutation from the list of permutations.ExampleIf permutation is = { “ABC”, “ACB”, “BAC”, “BCA”} then missing permutations are {“CBA” and “CAB”}AlgorithmCreate a set of all given stringsAnd one more set of all permutationsReturn difference between two setsExample Live Demo#include ... Read More

Missing even and odd elements from the given arrays in C++

Narendra Kumar

Narendra Kumar

Updated on 20-Dec-2019 10:29:28

293 Views

Problem statementGiven two integer arrays even [] and odd [] which contains consecutive even and odd elements respectively with one element missing from each of the arrays. The task is to find the missing elements.ExampleIf even[] = {10, 8, 6, 16, 12} and odd[] = {3, 9, 13, 7, 11} ... Read More

Mirror of n-ary Tree in C++

Narendra Kumar

Narendra Kumar

Updated on 20-Dec-2019 10:25:57

216 Views

Problem statementGiven a Tree where every node contains variable number of children, convert the tree to its mirrorExampleIf n-ary tree is −Then it’s mirror is −Example Live Demo#include using namespace std; struct node {    int data;    vectorchild; }; node *newNode(int x) {    node *temp = new node; ... Read More

Minimum XOR Value Pair in C++

Narendra Kumar

Narendra Kumar

Updated on 20-Dec-2019 10:21:42

148 Views

Problem statementGiven an array of integers. Find the pair in an array which has minimum XOR valueExampleIf arr[] = {10, 20, 30, 40} then minimum value pair will be 20 and 30 as (20 ^ 30) = 10. (10 ^ 20) = 30 (10 ^ 30) = 20 (10 ^ ... Read More

Minimum value that divides one number and divisible by other in C++

Narendra Kumar

Narendra Kumar

Updated on 20-Dec-2019 10:18:48

154 Views

Problem statementGiven two integer p and q, the task is to find the minimum possible number x such that q % x = 0 and x % p = 0. If the conditions aren’t true for any number, then print -1.ExampleIf p = 3 and q = 66 then answer ... Read More

Advertisements