Narendra Kumar has Published 191 Articles

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

Narendra Kumar

Narendra Kumar

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

765 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

924 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

365 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

450 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

181 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

307 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

210 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

199 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

Minimum steps to make all the elements of the array divisible by 4 in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:57:29

468 Views

Problem statementGiven an array of size n, the task iss to find the minimum number of steps required to make all the elements of the array divisible by 4. A step is defined as removal of any two elements from the array and adding the sum of these elements to ... Read More

Minimum steps to delete a string after repeated deletion of palindrome substrings in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:52:26

927 Views

Problem statementGiven a string containing characters as integers only. We need to delete all character of this string in a minimum number of steps where in one step we can delete the substring which is a palindrome. After deleting a substring remaining parts are concatenated.ExampleIf input string is 3441213 then ... Read More

Advertisements