Company: citi_14oct
Difficulty: medium
Longest Switching Slice Problem Description We call an array switching if all numbers in even positions are equal and all numbers in odd positions are equal. For example: [3, -7, 3, -7] and [4, 4, 4, 4] are switching, but [5, 5, 5, 4] and [-3, 2, 3] are not switching. What is the length of the longest switching slice (continuous fragment) in a given array A? Write a function: int solution(vector<int> &A); that, given an array A consisting of N integers, returns the length of the longest switching slice in A. Examples Example 1: Input: A = [3, 2, 3, 2, 3] Output: 5 Explanation: The function should return 5, because the whole array is switching. Example 2: Input: A = [7, 4, -2, 4, -2, -9] Output: 4 Explanation: The longest switching slice is [4, -2, 4, -2] . Example 3: Input: A = [7, -5, -5, -5, 7, -1, 7] Output: 3 Explanation: There are two switching slices of equal length: [-5, -5, -5] and [7, -1, 7] . Example 4: Input: A = [4] Output: 1 Explanation: A single-element slice is