Narendra Kumar has Published 196 Articles

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

191 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

650 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

Maximize number of 0s by flipping a subarray in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 06:57:49

641 Views

Problem statementGiven a binary array, find the maximum number of zeros in an array with one flip of a subarray allowed. A flip operation switches all 0s to 1s and 1s to 0sIf arr1= {1, 1, 0, 0, 0, 0, 0}If we flip first 2 1’s to 0’s, then we ... Read More

Maximize elements using another array in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 06:55:18

814 Views

Problem statementGiven two arrays with size n, maximize the first array by using the elements from the second array such that the new array formed contains n greatest but unique elements of both the arrays giving the second array priority i.e. all elements of the second array appear before the ... Read More

Maximize array sum after K negation in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 06:51:55

279 Views

Problem statementGiven an array of size n and a number k. We have to modify an array k number of times.Modify array means in each operation we can replace any array element arr[i] by negating it i.e. arr[i] = -arr[i]. The task is to perform this operation in such a ... Read More

Maximize array elements up to given numbers in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 06:47:07

360 Views

Problem statementGiven an array of integers, a number and a maximum value, the task is to compute the maximum value that can be obtained from the array elements. Every value on the array traversing from the beginning can be either added to or subtracted from the result obtained from the ... Read More

Maximize a given unsigned number by swapping bits at its extreme positions in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 06:43:22

116 Views

Problem statementGiven a number maximize it by swapping bits at its extreme positions i.e. at first and last position, second and second last position and so on.If the input number is 8 then its binary representation is−00000000 00000000 00000000 00001000After swapping bits at extreme positions number becomes −00010000 00000000 00000000 ... Read More

Maximal Disjoint Intervals in C++

Narendra Kumar

Narendra Kumar

Updated on 24-Dec-2019 06:39:21

194 Views

DescriptionGiven a set of N intervals, the task is to find the maximal set of mutually disjoint intervals. Two intervals [i, j] & [k, l] are said to be disjoint if they do not have any point in commonIf intervals are {{10, 20} {23, 35}, {15, 21}, {37, 41}} then ... Read More

Minimum sum falling path in a NxN grid in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 07:05:13

121 Views

Problem statementGiven a matrix A of integers of size NxN. The task is to find the minimum sum of a falling path through A.A falling path will start at any element in the first row and ends in last row.It chooses one element from each next row. The next row’s ... Read More

Minimum steps to remove substring 010 from a binary string in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 07:02:29

85 Views

Problem statementGiven a binary string, the task is to count the minimum steps to remove substring 010 from this binary stringExampleIf input string is 010010 then 2 steps are requiredConvert first 0 to 1. Now string becomes 110010Convert last 0 to 1. Now final string becomes 110011Algorithm1. Iterate the string ... Read More

Advertisements