Sunidhi Bansal has Published 1085 Articles

Maximum length of subarray such that sum of the subarray is even in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:52:38

919 Views

We are given with an array Arr[] of integers. The goal is to find longest length subarray of Arr[] , sum of whose elements is even. That is, the sum of elements of a subarray is even and that subarray is longest in length.Input − Arr[] = { 2, 3, ... Read More

Maximum number of candies that can be bought in C

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:50:11

831 Views

We are given an array of candies[] of length stored in ‘size’. Each element candies[i] has a number for candies of type i.The goal is to buy as many candies as possible for any amount of money. The conditions are as given −If you purchase X[i] of type i (0Read More

Maximum number of 2×2 squares that can be fit inside a right isosceles triangle in C

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:48:50

781 Views

We are given a right isosceles triangle. Isosceles triangle is the one which has two sides of equal length. Right triangle is the one which has height(ag in fig.) and base (dg in fig.) perpendicular to each other. The goal is to find the maximum number of squares that can ... Read More

Maximum no. of contiguous Prime Numbers in an array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:46:30

485 Views

We are given with an array of prime numbers, arranged in random order. The size of the array is N. The goal is to find the longest sequence of contiguous prime numbers in the array.Prime number is the one which has only two factors, 1 and the number itself. 1, ... Read More

Maximum consecutive repeating character in string in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:44:50

2K+ Views

We are given a string of alphabets. The task is to find the character which has the longest consecutive repetitions occurring in string. Let’s understand with examples.Input− String[] = “abbbabbbbcdd”Output − bExplanation − In the above string, the longest consecutive sequence is of character ‘b’. Count of consecutive b’s is ... Read More

Maximum consecutive one’s (or zeros) in a binary circular array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:43:21

772 Views

We are given with a circular array. Circular array is the array for which we consider the case that the first element comes next to the last element. It is used to implement queues. So we have to count the maximum no. of consecutive 1’s or 0’s in that array.Let’s ... Read More

Maximum bishops that can be placed on N*N chessboard in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:39:16

450 Views

We are given an input N which denotes the size of the chessboard. The task here is to find for any value of N, how many bishops can be placed on the NXN chessboard such that no two bishops can attack each other. Let’s understand with examples.Input − N=2Output− Maximum ... Read More

Count number of 1s in the array after N moves in C

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:37:01

456 Views

We are given an array of size N. The array has all 0’s initially. The task is to count the no. of 1’s in the array after N moves. Each Nth move has a rule associated. The rules are −1st Move − Change element at positions 1, 2, 3, 4…………..2nd ... Read More

Maximum binomial coefficient term value in C

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:33:47

249 Views

We are given with a positive integer ‘N’. We have to find the maximum coefficient term in all binomial coefficients.The binomial coefficient series is nC0, nC1, nC2, …., nCr, …., nCn-2, nCn-1, nCnfind the maximum value of nCr.nCr = n! / r! * (n - r)!Input − N=4Output − Maximum ... Read More

Maximize the difference between two subsets of a set with negatives in C

Sunidhi Bansal

Sunidhi Bansal

Updated on 17-Aug-2020 08:32:06

265 Views

We are given with an array of positive and negative integers. The task is to find the maximum difference between positive and negative subsets of elements present in the array. As we have subsets of positive and negative numbers. Then the difference (sum of positives) - (sum of negatives) will ... Read More

Advertisements