Consider an array X that contains positive integers. A subarray of X is defined to be a sequence of array locations with consecutive indices.
The C code snippet given below has been written to compute the length of the longest subarray of X that contains at most two distinct integers. The code has two missing expressions labelled (P) and (Q).
Which one of the following options gives the CORRECT missing expressions?
(Hint: At the end of the iteration, the value of len1 is the length of the longest subarray ending with X[] that contains all equal values, and len2 is the length of the longest subarray ending with X[] that contains at most two distinct values.)
c
- A(P) len1 + 1 (Q) len2 + 1
- B(P) 1 (Q) len1 + 1
- C(P) 1 (Q) len2 + 1
- D(P) len 2 + 1 (Q) len1 + 1

