How would you write an algorithm to find the longest contiguous subarray of readings that fall within a specific safe threshold?