Narendra Kumar has Published 196 Articles

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

Narendra Kumar

Narendra Kumar

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

141 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

84 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

72 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

142 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

Minimum operation to make all elements equal in array in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 05:56:20

2K+ Views

Problem statementGiven an array with n positive integers. We need to find the minimum number of operation to make all elements equal. We can perform addition, multiplication, subtraction or division with any element on an array element.ExampleIf input array is = {1, 2, 3, 4} then we require minimum 3 ... Read More

Minimum operations of given type to make all elements of a matrix equal in C++

Narendra Kumar

Narendra Kumar

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

203 Views

Problem statementGiven an integer K and a matrix of M x N, the task is to find the minimum number of operations required to make all the elements of the matrix equal. In a single operation, K can be added to or subtracted from any element of the matrix.ExampleIf input ... Read More

Minimum operations required to make all the array elements equal in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 05:32:38

2K+ Views

Problem statementGiven an array with n positive integers. We need to find the minimum number of operation to make all elements equal. We can perform addition, multiplication, subtraction or division with any element on an array element.ExampleIf input array is = {1, 2, 3, 4} then we require minimum 3 ... Read More

Minimum operations required to remove an array in C++

Narendra Kumar

Narendra Kumar

Updated on 23-Dec-2019 05:28:24

143 Views

DescriptionGiven an array of N integers where N is an even number. There are two kinds of operations allowed on the array.Increase the value of any element of an array by 1.If two adjacent elements in the array are consecutive prime number, delete both the element.The task is to find ... Read More

Max sum of M non-overlapping subarrays of size K in C++

Narendra Kumar

Narendra Kumar

Updated on 20-Dec-2019 10:39:21

171 Views

Problem statementGiven an array and two numbers M and K. We need to find sum of max M subarrays of size K (non-overlapping) in the array. (Order of array remains unchanged). K is the size of subarrays and M is the count of subarray. It may be assumed that size ... Read More

Missing Permutations in a list in C++

Narendra Kumar

Narendra Kumar

Updated on 20-Dec-2019 10:34:29

66 Views

Problem statementGiven a list of permutations of any word. Find the missing permutation from the list of permutations.ExampleIf permutation is = { “ABC”, “ACB”, “BAC”, “BCA”} then missing permutations are {“CBA” and “CAB”}AlgorithmCreate a set of all given stringsAnd one more set of all permutationsReturn difference between two setsExample Live Demo#include ... Read More

Advertisements