Narendra Kumar has Published 196 Articles

Minimum positive integer required to split the array equally in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 11:04:23

126 Views

Problem statementGiven an array of N positive integers, the task is to find the smallest positive integer that can be placed between any two elements of the array such that, the sum of elements in the subarray occurring before it, is equal to the sum of elements occurring in the ... Read More

Minimum possible final health of the last monster in a game in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 10:58:54

312 Views

Problem statementGiven N monsters, each monster has initial health h[i] which is an integer. A monster is alive if its health is greater than 0.In each turn a random monster kills another random monster, the monster which is attacked, its health reduces by the amount of health of the attacking ... Read More

Minimum number of Square Free Divisors in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 10:54:48

123 Views

Problem statementGiven an integer N. Find the minimum number of square free divisors.The factorization of N should comprise of only those divisors that are not full squareExampleIf N = 24 then there are 3 square free factors as follows −Factors = 2 * 6 * 2AlgorithmFind all prime factors upto ... Read More

Minimum number of single digit primes required whose sum is equal to N in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Nov-2019 10:48:56

135 Views

Problem statementFind the minimum number of single-digit prime numbers required whose sum will be equal to N.ExampleIf N = 9 then we require 2 prime numbers i.e. 7 and 2 to make sum 9.Example#include using namespace std; bool isValidIndex(int i, int val) {    return (i - val) < ... Read More

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

Narendra Kumar

Narendra Kumar

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

376 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

121 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

235 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

918 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

289 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

309 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

Advertisements