start
and end
, to track the start and end of the current turbulent subarray, and a variable max_length
to store the maximum length found.end
pointer, starting from the second element.max_length
if the length of the current subarray (end - start
) is greater than max_length
.start
to end
to begin a new subarray.max_length
as the result.