This is my solution to LoveBabbar's 2nd question(Catch Fish), but it's showing as TLE (n ^ 2).. I'm not getting how it is going n ^ 2, can anyone help?

import java.util.*;
public class Solution {

public static int minimumNet(int n, int k, boolean[] fish){
    // Write your code here.
    int ans = Integer.MAX_VALUE;
    boolean catchingPossible = checkPossibleOrNot(fish, k);
    if (!catchingPossible) {
        return -1;
    }
    ans = getMinimumLength(fish, k, ans);
    return ans;
}
private static int getMinimumLength(boolean[] fish, int k, int ans) {
    int count = 0, len = 0;
    Queue<Integer> q = new LinkedList<>();
    for (int i = 0; i < fish.length; i++) {
        if (fish[i]) {
            count++;
            q.add(i - 1);
        } 
        if (count == k) {
            len = i - q.poll();
            if (len < ans) {
                ans = len;
            }
            count--;
        }
    }
    return ans;
}
private static boolean checkPossibleOrNot(boolean[] fish, int k) {
    int count = 0;
    for (int i = 0; i < fish.length; i++) {
        if (fish[i]) {
            count++;
        }
    }
    return count >= k;
}

}

Same Happens with me as well in C++. If you are able to find out the solution please help me as well.