For this Question: Given an integer array nums and an integer k, print the number of good subarrays of nums.

A good array is an array where the number of different integers in that array is exactly k.

For example, [1, 2, 3, 1, 2] has 3 different integers: 1, 2, and 3.

A subarray is a contiguous part of an array.First line contains n - size of the nums and k.
Next line contains n space separated integers.

<b>Constraints</b>
1 <= k < n <= 10<sup>4</sup>
1 <= nums[i] <= nA single integer denoting required answer.Input:
5 3
1 2 1 3 4 

Output:
3

Explanation:
{1, 2, 1, 3}, {2, 1, 3} and {1, 3, 4}, I have written this Solution Code: import java.io.*;
import java.util.*;


public class Main {
    
    
    public static int atmost(int[] nums, int k){
        int res = 0;
        HashMap<Integer,Integer> map = new HashMap<>();
        int j = -1;
        for(int i = 0; i<nums.length; i++){
            map.put(nums[i],map.getOrDefault(nums[i],0)+1);
            while(j<i && map.size()>k){
                j++;
                if(map.get(nums[j])==1){
                    map.remove(nums[j]);
                }else{
                    map.put(nums[j],map.get(nums[j])-1);
                }
            }
            res += i-j;
        }
        return res;
    }
    
    public static void main(String[] args) {
        
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);

        int n=Integer.parseInt(in.next());
        int k=Integer.parseInt(in.next());
        
        int nums[] = new int[n];
        for(int i=0;i<n;i++){
            nums[i] = Integer.parseInt(in.next());
        }
        int ans=atmost(nums,k) - atmost(nums,k-1);
        
        out.print(ans);
        out.close();
    }

    
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }
}
, In this Programming Language: Java, Now tell me if this Code is compilable or not?