1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit - sliding win +heap
T: O(nlogn)
s: O(n)
```javaclassSolution {publicintlongestSubarray(int[] nums,int limit) {Queue<Integer> minHeap =newPriorityQueue<>();Queue<Integer> maxHeap =newPriorityQueue<>((a, b) -> b - a);int n =nums.length;int left =0;int right =0;int result =0;while (right < n) {int rightInt = nums[right]; right++;minHeap.offer(rightInt);maxHeap.offer(rightInt);while (maxHeap.peek() -minHeap.peek() > limit) {int leftInt = nums[left]; left++;minHeap.remove(leftInt);maxHeap.remove(leftInt); } result =Math.max(result, right - left); }return result; }}/*absolute difference between any two elements of this subarray is less than or equal to limit.abs diff <= limit[8,2,4,7] -> not work 8-2 > limit 4[8,2,4,7]maxHeap -> 8 2minHeap -> 8 2sliding win -> but needs max and min heapuse monoqueue or use maxheap, min heap8 2 4 7[]*/```