Narendra Kumar has Published 196 Articles

Maximum determinant of a matrix with every values either 0 or n in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 12:22:55

81 Views

Problem statementWe have given a positive number n, and we have to find a 3*3 matrix which can be formed with combination of 0 or n and has maximum determinants.ExampleIf n = 15 then we can create matrix as follows −{{15, 15, 0}{0, 15, 15}{15, 0, 0}}For any 3*3 matrix ... Read More

Maximum Bitwise AND pair from given range in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 12:19:58

85 Views

Problem statementGiven a range [L, R], the task is to find a pair (X, Y) such that L ≤ X < Y ≤ R and X & Y is maximum among all the possible pairs then print the bitwise AND of the found pair.ExampleIf L = 1 and R = ... Read More

Maximum average sum partition of an array in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 12:17:51

136 Views

Problem statementGiven an array, we partition a row of numbers A into at most K adjacent (non-empty) groups, then the score is the sum of the average of each group. What is the maximum score that can be scored?ExampleIf input array is {9, 2, 5, 3, 10} then we can ... Read More

Maximum average of a subarray of size of at least X and at most Y in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 12:13:14

176 Views

Problem statementGiven an array arr[] and two integers X and Y. The task is to find a sub-array of size of at least X and at most Y with the maximum averageExampleIf input array is {2, 10, 15, 7, 8, 4} and x = 3 and Y = 3 then ... Read More

Maximum array from two given arrays keeping order same in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 12:10:02

103 Views

Problem statementGiven two same sized arrays A[] and B[]. Task is to form a third array of same size. The result array should have maximum n elements from both array. It should have chosen elements of A[] first, then chosen elements of B[] in same order as they appear in ... Read More

Maximum area of quadrilateral in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 12:05:22

244 Views

Problem statementGiven four sides of quadrilateral a, b, c, d, find the maximum area of the quadrilateral possible from the given sides.AlgorithmWe can use below Brahmagupta’s formula to solve this problem −√(s-a)(s-b)(s-c)(s-d)In above formula s is semi-perimeter. It is calculated as follows −S = (a + b + c + ... Read More

Maximum bitwise AND value of a pair in an array in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 12:02:53

515 Views

Problem statementGiven an array of n positive elements. we need to find the maximum bitwise AND value generated by any pair of element from the array.ExampleIf input array is {10, 12, 15, 18} then maximum value of bitwise AND is 12.AlgorithmThe result of bitwise AND operations on single bit is ... Read More

Maximum and Minimum in a square matrix in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 11:58:50

133 Views

Problem statementGiven a square matrix of order n*n, find the maximum and minimum from the matrixExampleIf given matrix is −{{15, 17, 19}, {5, 1, 7}, {14, 5, 16}} then Minimum number is 1 and maximum number is 19AlgorithmSelect two elements from the matrix one from the start of a row ... Read More

Maximum 0’s between two immediate 1’s in binary representation in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 11:53:54

731 Views

Problem statementGiven a number n, the task is to find the maximum 0’s between two immediate 1’s in binary representation of given n. Return -1 if binary representation contains less than two 1’sExampleIf input number is 35 then its binary representation is −00100011In above binary representation there are 3 0’s ... Read More

Maximum element in min heap in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 11:48:37

275 Views

Problem statementGiven a minimum heap find maximum element in that.ExampleIf input heap is −Then maximum element is 55AlgorithmIn minimum heap parent node will be lesser than its children. Hence we can conclude that a non-leaf node cannot be the maximum.Search maximum element in the leaf nodesExampleLet us now see an ... Read More

Previous 1 ... 6 7 8 9 10 ... 20 Next
Advertisements