Narendra Kumar has Published 191 Articles

Minimum number of sets with numbers less than Y in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 10:43:13

497 Views

Problem statementGiven a string of consecutive digits and a number Y, the task is to find the number of minimum sets such that every set follows the below rule −Set should contain consecutive numbersNo digit can be used more than once.The number in the set should not be more than ... Read More

Minimum number of prefix reversals to sort permutation of first N numbers in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 10:37:32

333 Views

DescriptionGiven an array of N numbers which have a permutation of first N numbers. In a single operation, any prefix can be reversed. The task is to find the minimum number of such operations such that the numbers in the array are in sorted in increasing order.ExampleIf array is {1, ... Read More

Minimum number of Parentheses to be added to make it valid in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 10:11:46

299 Views

Problem statementGiven a string of parentheses. It can container opening parentheses ’(‘ or closing parentheses ‘)’. We have to find minimum number of parentheses to make the resulting parentheses string is valid.ExampleIf str = “((()” then we required 2 closing parentheses i.e ‘))’ at end of stringAlgorithmCount opening parenthesesCount closing ... Read More

Minimum number of bottles required to fill K glasses in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 10:06:15

1K+ Views

Problem statementGiven N glasses having water, and a list of each of their capacity. The task is to find the minimum number of bottles required to fill out exactly K glasses. The capacity of each bottle is 100 units.ExampleIf N = 5, K = 4, capacity[] = {1, 2, 3, ... Read More

Minimum number of Appends needed to make a string palindrome in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 10:01:29

427 Views

Problem statementGiven a string, find minimum characters to be appended to make a string palindrome.ExampleIf string is abcac then we can make string palindrome by appending 2 highlighed characters i.e. abcacbaAlgorithmCheck if string is already palindrome, if yes then no need to append any characters.One by one remove a character ... Read More

Minimum move to end operations to make all strings equal in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 09:56:34

409 Views

Problem statementGiven n strings that are permutations of each other. We need to make all strings same with an operation that moves first character of any string to the end of it.ExampleIf arr[] = {“abcd”, “cdab”} then 2 moves are required.Let us take first string “abcd”. Move character ‘a’ to ... Read More

Minimum flips to make all 1s in left and 0s in right in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 09:52:57

388 Views

Problem statementGiven a binary string in which we can flip all 1’s in left part and all 0’s in right part. The task is to calculate minimum flips required to make all 1’s in left and all 0’s in rightExampleGiven binary string is 0010101. In this string there are 3 ... Read More

Minimum height of a triangle with given base and area in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 09:49:26

275 Views

DescriptionGiven two integers a and b, find the smallest possible height such that a triangle of atleast area ‘a’ and base ‘b’ can be formed.ExampleIf a = 16 and b = 4 then minimum height would be 8AlgorithmArea of triangle can be calculate using below formula −area = ½ * ... Read More

Minimum number of power terms with sum equal to n using C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 07:40:40

286 Views

Problem statementGiven two positive integer N and X. The task is to express N as a sum of powers of X (X0 + X1 +…..+ Xn) such that the number of powers of X should be minimum.Print the minimum number of power of N used to make the sum equal ... Read More

Minimum number of points to be removed to get remaining points on one side of axis using C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 07:37:14

581 Views

Problem statementWe are given N points in a Cartesian plane. Our task is to find the minimum number of points that should be removed in order to get the remaining points on one side of any axis.If given input is {(10, 5), (-2, -5), (13, 8), (-14, 7)} then if ... Read More

Advertisements