Given an array of integers and an integer k, your task is to find the length of the longest contiguous subarray that contains at most k distinct integers.
Note: As we approach the end of November, a time often remembered for reflection and unity, think of this problem as finding a harmonious segment within a larger sequence, where a small number of unique values create a balanced whole.
Assume that k is at most the total number of distinct integers in the array.