Sunidhi Bansal has Published 1100 Articles

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

Sunidhi Bansal

Sunidhi Bansal

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

356 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

563 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

286 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

349 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

125 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

140 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

Maximum and minimum of an array using minimum number of comparisons in C

Sunidhi Bansal

Sunidhi Bansal

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

12K+ Views

We are given with an array of integers. The task is to find the minimum and maximum element of the array in the minimum number of comparisons.Input Arr[] = { 1, 2, 4, 5, -3, 91 }Output Maximum element : 91 Minimum Element : -3Explanation − Here to minimize the number of ... Read More

Maximum absolute difference of value and index sums in C

Sunidhi Bansal

Sunidhi Bansal

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

724 Views

We are given with an array of integers. The task is to calculate the maximum absolute difference of value and index sums. That is for each pair of indexes (i, j) in an array, we have to calculate | Arr[i] - A[j] | + |i-j| and find the maximum such ... Read More

Different methods to copy in C++ STL - std::copy(), copy_n(), copy_if(), copy_backwards()

Sunidhi Bansal

Sunidhi Bansal

Updated on 14-Aug-2020 08:43:35

325 Views

As the method name suggests copy() method is used to copy the data through various methods available in C++ STL. All the methods differ in functionalities and the parameters. These methods are available in header file. Let’s discuss each method and their functionalities.Copy(start_i1, end_i1, start_i2)This method is used to ... Read More

Advertisements