We have an array A of integers of size N. Given another array B which contains indices, where size of B <= N and 0<=B[i]<=N-1.
Now we have to remove all elements from array A at position B[i].
So with deletion we mean we are also shifting elements in array A.
Can someone help me in reaching to O(n) solution for this problem? And possibly O(1) space.
The first solution that comes to my mind is, traversing the array B and deleting elements in A sequentially( including shifting) but it is O(n^2).