Narendra Kumar has Published 191 Articles

Maximizing array sum with given operation in C++

Narendra Kumar

Narendra Kumar

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

170 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

225 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

307 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

448 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

186 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

163 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

333 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

251 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

Maximize the maximum subarray sum after removing at most one element in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 07:03:04

302 Views

Problem statementGiven an array arr[] of N integers. The task is to first find the maximum sub-array sum and then remove at most one element from the sub-array. Remove at most a single element such that the maximum sum after removal is maximized.If given input array is {1, 2, 3, ... Read More

Maximize the bitwise OR of an array in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 06:59:33

823 Views

Problem statementGiven an array of N integers. The bitwise OR of all the elements of the array has to be maximized by performing one task. The task is to multiply any element of the array at-most k times with a given integer xIf input array is {4, 3, 6, 1}, ... Read More

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