Narendra Kumar has Published 196 Articles

Maximizing Unique Pairs from two arrays in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 11:45:55

248 Views

Problem statementGiven two arrays of equal size N, form maximum number of pairs by using their elements, one from the first array and second from the second array, such that an element from each array is used at-most once and the absolute difference between the selected elements used for forming ... Read More

Maximizing the elements with a[i+1] > a[i] in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 11:41:55

169 Views

Problem statementGiven an array of N integers, rearrange the array elements such that the next array element is greater than the previous element arr[i+1] > arr[i]ExampleIf input array is {300, 400, 400, 300} then rearranged array will be −{300, 400, 300, 400}. In this solution we get 2 indices with ... Read More

Maximizing array sum with given operation in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 11:38:48

100 Views

DescriptionThere is an array of (2 * n – 1) integers. We can change sign of exactly n elements in the array. In other words, we can select exactly n array elements, and multiply each of them by -1. Find the maximum sum of the array.ExampleIf input array is {-2, ... Read More

Maximize value of (arr[i] – i) – (arr[j] – j) in an array in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 07:21:26

148 Views

Problem statementGiven an array, arr[] find the maximum value of (arr[i] – i) – (arr[j] – j) where i is not equal to j. Where i and j vary from 0 to n-1 and n is the size of input array arr[].If the input array is {7, 5, 10, 2, ... Read More

Maximize the value of the given expression in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 07:17:59

208 Views

Problem statementGiven three non-zero integers a, b and c. The task is to find the maximum value possible by putting addition and multiplication signs between them in any order.Please note that rearrangement of integers is allowed but addition and multiplication sign must be used once.If a = 1, b = ... Read More

Maximize the sum of arr[i]*i in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 07:15:21

315 Views

Problem statementGiven an array of N integers. You are allowed to rearrange the elements of the array. The task is to find the maximum value of Σarr[i]*i, where i = 0, 1, 2, .. n – 1.If input array = {4, 1, 6, 2} then the maximum sum will be ... Read More

Maximize the number of segments of length p, q and r in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 07:12:10

110 Views

Problem statementGiven a rod of length L, the task is to cut the rod in such a way that the total number of segments of length p, q and r is maximized. The segments can only be of length p, q, and rIf l = 15, p = 2, q ... Read More

Maximize the number by rearranging bits in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 07:09:42

65 Views

Problem statementGiven an unsigned number, find the maximum number that could be formed by using the bits of the given unsigned numberIf the input number is 8 then its binary representation is−00000000000000000000000000001000To maximize it set MSB to 1. Then number becomes 2147483648 whose binary representation is−10000000000000000000000000000000Algorithms1. Count number of set ... Read More

Maximize the median of the given array after adding K elements to the same array in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 07:07:25

168 Views

Problem statementGiven an array arr[] of N elements and an integer K where K < N. The task is to insert K integer elements to the same array such that the median of the resultant array is maximizedIf input array is {1, 3, 2, 5} and k = 3 then ... Read More

Maximize the median of an array in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 07:05:41

158 Views

Problem statementGiven an array arr[] of N elements and an integer K where K < N. The task is to insert K integer elements to the same array such that the median of the resultant array is maximizedIf input array is {1, 3, 2, 5} and k = 3 then−Sorted ... Read More

Previous 1 ... 7 8 9 10 11 ... 20 Next
Advertisements