Narendra Kumar has Published 191 Articles

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

Narendra Kumar

Narendra Kumar

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

305 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 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

145 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

368 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

237 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

168 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

606 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

Minimum number using set bits of a given number in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:12:59

214 Views

Problem statementGiven an unsigned number, find the minimum number that could be formed by using the bits of the given unsigned number.ExampleIf input = 10 then answer would be 3Binary representation of 10 is 1010 and minimum number with 2 set bits is 0011 i.e. 3Algorithm1. Count the number of ... Read More

Minimum number with digits as and 7 only and given sum in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 06:08:25

137 Views

Problem statementLucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. The task is to find minimum lucky number has the sum of digits equal to n.ExampleIf sum = 22 then lucky number is 4477 as 4 + 4 + 7 + 7 ... Read More

Minimum numbers which is smaller than or equal to N and with sum S in C++

Narendra Kumar

Narendra Kumar

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

101 Views

Problem statementGiven N numbers from 1 to N and a number S. The task is to print the minimum number of numbers that sum up to give SExampleIf n = 7 and s = 10 then minimum 2 numbers are required(9, 1) (8, 2) (7, 3) (6, 4)AlgorithmAnswer can be ... Read More

Minimum numbers needed to express every integer below N as a sum in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 05:59:39

227 Views

Problem statementWe have an integer N. We need to express N as a sum of K integers such that by adding some or all of these integers we can get all the numbers in the range 1 to N. The task is to find minimum value of KExampleIf N = ... Read More

Advertisements