CBSE BOARD XII, asked by mohammadarifa1994, 20 days ago

givn an array of N integers,find the maximum length subarray that contains similar elements

Answers

Answered by priyanshis562
0

Given - an array of N integers

To Find - the maximum length of sub-array that contains similar elements

Solution -

For example -

Input: arr[] = {2, 3, 4, 4, 5, 5, 6, 7, 8, 10}  

Explanation:

{2, 3}, {3, 4}, {4, 4, 5, 5}, {5, 6}, etc, are the valid sub-arrays where both halves have only one type of element.  

{4, 4, 5, 5} is the sub-array having maximum length.

Hence, the output is 4.

Similar questions