If I understand the question correctly, this is really straightforward and can be done in 1 pass. Code as following
def vip_partitioning(arr):
before = {}
after = {}
seen_vip = False
for x in arr:
if x == 'vip':
seen_vip = True
continue
if seen_vip:
if x in after:
after[x] += 1
else:
after[x] = 1
else:
if x in before:
before[x] += 1
else:
before[x] = 1
Then you have before and after which maps the
Value in the array to its occurrences.
The idea is if the array value not in the dict,
it means the occurrence is 0.
Let me know if I am understanding this correctly.
Best~