Narendra Kumar has Published 191 Articles

Maximum length of a sub-array with ugly numbers in C++

Narendra Kumar

Narendra Kumar

Updated on 10-Jan-2020 07:31:31

119 Views

Problem statementGiven an array arr[] of N elements (0 ≤ arr[i] ≤ 1000). The task is to find the maximum length of the sub-array that contains only ugly numbers.Ugly numbers are numbers whose only prime factors are 2, 3 or 5.For Example below are the few number from series: 1, ... Read More

Maximum height of triangular arrangement of array values in C++

Narendra Kumar

Narendra Kumar

Updated on 10-Jan-2020 07:21:57

131 Views

Problem statementGiven an array, we need to find the maximum height of the triangle which we can form, from the array values such that every (i+1)th level contain more elements with the larger sum from the previous level.ExampleIf input array is {40, 100, 20, 30 } then answer is 2 ... Read More

Maximum games played by winner in C++

Narendra Kumar

Narendra Kumar

Updated on 10-Jan-2020 07:19:37

488 Views

Problem statementThere are N players which are playing a tournament. We need to find the maximum number of games the winner can play. In this tournament, two players are allowed to play against each other only if the difference between games played by them is not more than oneExampleIf There ... Read More

Maximum even length sub-string that is permutation of a palindrome in C++

Narendra Kumar

Narendra Kumar

Updated on 10-Jan-2020 07:16:22

165 Views

Problem statementGiven a string the task is to find the maximum length of the sub-string of that can be arranged into a Palindrome.ExampleIf input string = “5432112356” then answer is 6 as maximum palindrome substring is “321123” and its length is 6AlgorithmIf the length of the sub-string is odd, then ... Read More

Maximum equlibrium sum in an array in C++

Narendra Kumar

Narendra Kumar

Updated on 10-Jan-2020 07:10:53

424 Views

Problem statementGiven an array arr[]. Find maximum value of prefix sum which is also suffix sum for index i in arr[].ExampleIf input array is −Arr[] = {1, 2, 3, 5, 3, 2, 1} then output is 11 as −Prefix sum = arr[0..3] = 1 + 2 + 3 + 5 ... Read More

Maximum element in a very large array using pthreads in C++

Narendra Kumar

Narendra Kumar

Updated on 10-Jan-2020 07:07:59

478 Views

Problem statementGiven a very large array of integers, find maximum within the array using multithreadingExampleIf input array is {10, 14, -10, 8, 25, 46, 85, 1673, 63, 65, 93, 101, 125, 50, 73, 548} thenmaximum element in this array is 1673AlgorithmLet us call array size as total_elementsCreate N threadsEach thread ... Read More

Maximum element between two nodes of BST in C++

Narendra Kumar

Narendra Kumar

Updated on 31-Dec-2019 13:39:16

246 Views

Problem statementGiven an array of N elements and two integers A, B which belongs to the given array. Create a Binary Search Tree by inserting element from arr[0] to arr[n-1]. The task is to find the maximum element in the path from A to B.ExampleIf array is {24, 23, 15, ... Read More

Maximum edge removal from tree to make even forest in C++

Narendra Kumar

Narendra Kumar

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

409 Views

Problem statementGiven an undirected tree which has even number of vertices, we need to remove the maximum number of edges from this tree such that each connected component of the resultant forest has an even number of vertices.ExampleIn above shown tree, we can remove at max 2 edges 0-2 and ... Read More

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

123 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

120 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

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