Narendra Kumar has Published 196 Articles

Minimum flips required to maximize a number with k set bits in C++.

Narendra Kumar

Narendra Kumar

Updated on 23-Sep-2019 10:49:41

110 Views

Problem statementGiven two numbers n and k, we need to find the minimum number of flips required to maximize given number by flipping its bits such that the resulting number has exactly k set bits. Please note input must satify condition that k < number of bits in n.ExampleLet us ... Read More

Minimum flips in two binary arrays so that their XOR is equal to another array in C++.

Narendra Kumar

Narendra Kumar

Updated on 23-Sep-2019 10:41:53

94 Views

Problem statementGiven three arrays with 0’s and 1’s of size n, the task is to find minimum flip of bits in the first and second array such that the XOR of i’th index bit of first and second array is equal to i’th index bit of the third array.Please note ... Read More

Minimum element in a max heap in C++.

Narendra Kumar

Narendra Kumar

Updated on 23-Sep-2019 10:34:50

283 Views

Problem statementFind the element with the least value in max heap.Let us consider below max heap.In max heap value of the root node is always greater than its childer. Because of this property, we can conclude that value will be present in one of the leaf nodes. If heap contains ... Read More

Minimum delete operations to make all elements of array same in C++.

Narendra Kumar

Narendra Kumar

Updated on 23-Sep-2019 10:29:22

128 Views

Problem statementGiven an array of n elements such that elements may repeat. We can delete any number of elements from array. The task is to find a minimum number of elements to be deleted from array to make it equal.arr[] = {10, 8, 10, 7, 10, -1, -4, 12}We have ... Read More

Minimum and Maximum Prime Numbers of a Singly Linked List in C++.

Narendra Kumar

Narendra Kumar

Updated on 23-Sep-2019 10:25:58

106 Views

Problem statementGiven a linked list of n positive integers. We have to find the prime number with minimum and maximum value.If the given list is −10 -> 4 -> 1 -> 12 -> 13 -> 7 -> 6 -> 2 -> 27 -> 33 then minimum prime number is 2 ... Read More

C Program to Minimum and Maximum prime numbers in an array

Narendra Kumar

Narendra Kumar

Updated on 23-Sep-2019 10:21:56

557 Views

Problem statementGiven an array of n positive integers. We have to find the prime number with minimum and maximum value.If the given array is −arr [] = {10, 4, 1, 12, 13, 7, 6, 2, 27, 33} then minimum prime number is 2 and maximum prime number is 13Algorithm1. Find ... Read More

Advertisements