GeeksforGeeks Question Doubt

Please look this question from the following link =

https://practice.geeksforgeeks.org/problems/linear-probing-in-hashing-1587115620/0/?track=DSASP-Hashing&batchId=154

I am getting TLE from the following code. Please help.

static int[] linearProbing(int hash_size, int arr[], int N) {
    int[] a = new int[hash_size];
    for(int i = 0; i < hash_size; i++)
        a[i] = -1;
    for(int i = 0; i < N; i++) {
        int probe = arr[i] % hash_size;
        int offset = 1;
        while(a[probe] != -1) {
            probe = (probe + offset) % hash_size;
        }
        a[probe] = arr[i];
    }
    return a;
}