Given is a list with unsorted indices in a list of length n. Each element of the list is only once contained. So the list looks like this
L = [13, 145, 70001, 34, ..., 533]
Also given is a dictionary d
which numerical values as key. All values are element
{0,1}
. Like
d = {
"[some data]" : 0,
"[some data]" : 1,
"[some data]" : 1,
"[some data]" : 1,
...
"[some data]" : 0
}
There are a lot more entries in the dictionary d
then in the list L
.
What I want to do is deleting data from the dictionary for each position (index) from L
if it is a 0
.
The problem that I see while proceeding it that after the each deletion the indices need to be shifted since the position within dictionary is changing. Which is quiet inefficient regarding on a large number of items in L
. There must be an efficient way of proceeding this task.
Any ideas and suggestions are highly appreciated!