Narendra Kumar has Published 196 Articles

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

379 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

764 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

Minimum rotations required to get the same string in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:45:35

227 Views

Problem statementGiven a string, we need to find the minimum number of rotations required to get the same stringExampleIf input string is “bbbbb” then minimum 1 rotation is requiredAlgorithm1. Initialize result = 0 2. Make a temporary string equals to original string concatenated with itself. 3. Take the substring of ... Read More

Minimum removals to make array sum odd in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:42:37

165 Views

Problem statementGiven an array arr[] of N integers. We need to write a program to find minimum number of elements needed to be removed from the array, so that sum of remaining element is odd.ExampleIf input array is {10, 20, 30, 5, 7} then we need to remove one element ... Read More

Minimum removals to make array sum even in C++

Narendra Kumar

Narendra Kumar

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

159 Views

Problem statementGiven an array arr[] of N integers. We need to write a program to find minimum number of elements needed to be removed from the array, so that sum of remaining element is even.ExampleIf input array is {10, 20, 30, 5} then we need to remove one element i.e. ... Read More

Minimum removals in a number to be divisible by 10 power raised to K in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:36:22

77 Views

Problem statementGiven two positive integers N and K. Find the minimum number of digits that can be removed from the number N such that after removals the number is divisible by 10K. Print -1 if it is impossible.ExampleIf N = 10203027 and K = 2 then we have to remove ... Read More

Minimum removals from array to make max – min <= K in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:32:46

237 Views

Problem statementGiven N integers and K, find the minimum number of elements that should be removed such that Amax - Amin

Minimum removal to make palindrome permutation in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:27:04

158 Views

Problem statementGiven a string S, we have to find minimum characters that we can remove to make any permutation of the string S a palindromeExampleIf str = “abcdba” then we remove to 1 character i.e. either ‘c’ or ‘d’.Algorithms1. There can be two types of a palindrome, even length, and ... Read More

Minimum number of stops from given path in C++

Narendra Kumar

Narendra Kumar

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

96 Views

Problem statementThere are many points in two-dimensional space which need to be visited in a specific sequence.Path from one point to other is always chosen as shortest path and path segments are always aligned with grid lines.We are given the path which is chosen for visiting the points. We need ... Read More

Minimum number of swaps required to sort an array in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:19:04

440 Views

Problem statementGiven an array of N distinct elements, find the minimum number of swaps required to sort the arrayExampleIf array is {4, 2, 1, 3} then 2 swaps are requiredSwap arr[0] with arr[2]Swap arr[2] with arr[3}Algorithm1. Create a vector of pair in C++ with first element as array alues and ... Read More

Advertisements