You can also map each value in arr to a dictionary, indicating if it's index is present in idx:
arr = [1, 2, 3, 4, 5, 6, 7, 8]
idx = [0, 3, 4, 6]
# converted to a set
idx_lookup = set(idx)
d = {x: True if i in idx_lookup else False for i, x in enumerate(arr)}
print(d)
Which gives this dictionay:
{1: True, 2: False, 3: False, 4: True, 5: True, 6: False, 7: True, 8: False}
I also converted idx to a set since in this case, duplicate indices are not necessary, and set/dictionary lookup is O(1). However, list lookup is O(n), so this optimization is worth it if possible.
Once you have this dictionary, you can filter out the elements you want to keep, and the rest of the elements from this:
keep = list(filter(lambda x: d[x], arr))
rest = list(filter(lambda x: not d[x], arr))
print(keep)
print(rest)
Which Outputs:
[1, 4, 5, 7]
[2, 3, 6, 8]
Note: You can also use list comprehensions above filtering of keep and rest:
keep = [x for x in arr if d[x]]
rest = [x for x in arr if not d[x]]