Narendra Kumar has Published 196 Articles

Maximum length of rod for Qth person in C++

Narendra Kumar

Narendra Kumar

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

97 Views

Problem statementGiven lengths of n rods in an array. If any person picks any rod, half of the longest rod (or (max + 1) / 2 ) is assigned and remaining part (max – 1) / 2 is put back. It may be assumed that sufficient number of rods are ... Read More

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

Narendra Kumar

Narendra Kumar

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

63 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

52 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

383 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

89 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

332 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

333 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 in a sorted and rotated array in C++

Narendra Kumar

Narendra Kumar

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

359 Views

DescriptionGiven a sorted array of distinct elements which is rotated at some unknown point, the task is to find the maximum element in it.ExampleIf input array is {30, 40, 50, 10, 20} then maximum element is 50.AlgorithmThe maximum element is the only element whose next is smaller than it. If ... Read More

Maximum element between two nodes of BST in C++

Narendra Kumar

Narendra Kumar

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

175 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

279 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

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