Write a function that takes an array of integers as input and returns the length of longest sub array that contains at most two distinct integers.

Technical