Write a function to solve a specific problem, and be prepared to code during the interview for RTI International.
Implement longest_subarray_at_most_k_distinct(nums, k), which returns the length of the longest contiguous subarray containing at most k distinct integers. Use a zero-based integer array and assume 1 <= k <= len(nums).
def longest_subarray_at_most_k_distinct(nums, k):