an array A1 containing N objects.another array A2 containing numbers that represent indexes into the first array. You need to remove elements from A1 for which indexes are there in A2 and produce the compacted array. For example:

```
A1 = [ a, b, c, d, e, f, g ] // N elements and N is large
A2 = [ 5, 1 ] // k elements and k is small (and constant)
Answer = [ a, c, d, e, g, _, _ ]

```

I wrote the C# code like : 

```
public class CompactingArray
{
    private Compact(array A1 , array A2)
    {
        var hash = new Hashset<int>(A2);
        foreach(int c in hash)
        {
            A1.remove(c,1);
        }

        Console.WriteLine(A1);
    }
}

```

I need O(n) complexity code and not to use any inbuilt functions. Please suggest a C# code without using any built-in functions.