Computer Sciences > Gate 2024 Set-2 > Thread
Consider an array X that contains n 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 (π)β‘and (π).
Which one of the following options gives the CORRECT missing expressions?
(Hint: At the end of the i-th iteration, the value of len1 is the length of the longest subarray ending with X[i] that contains all equal values, and len2 is the length of the longest subarray ending with X[i] that contains at most two distinct values.)

(Hint: At the end of the i-th iteration, the value of len1 is the length of the longest subarray ending with X[i] that contains all equal values, and len2 is the length of the longest subarray ending with X[i] that contains at most two distinct values.)
Correct : a
Similar Questions
Consider a multi-threaded program with two threads T1 and T2. The threads share
two semaphores: s1 (initialized to 1) and s2 (initialized to 0). The threads a...
Consider the following expression: π₯[π]=(π+π)ββπ [π]+π’/π€. The following
sequence shows the list of triples representing the given expression, with entries
mi...
Let π be the 5-state NFA with π-transitions shown in the diagram below.
Which one of the following regular expressions represents the language accepted...
Total Unique Visitors
Loading......