left and right to represent the window's boundaries.pair_count to keep track of the number of pairs in the window.right pointer, adding elements to the window and updating the hash map and pair_count.pair_count is at least k, increment the left pointer to shrink the window until pair_count is less than k.right pointer where pair_count is at least k, add the number of good subarrays ending at right to the result.