Skip to contentKEEP THE CRAFTTHE SANCTUARY

Mark Seen Indices

Record which labels from 1 to n appear by sending label v to index v - 1.

The problem

Implement mark_seen_indices(values). Every value is an integer label from 1 to n, where n = len(values). Labels can repeat, so some labels may be missing. Return a list of n booleans where position i is True exactly when label i + 1 appears in values. For example, [4, 1, 4, 2] gives [True, True, False, True], and [1, 1] gives [True, False]. values may be empty.

Starter code

def mark_seen_indices(values):
    pass

Public examples

  1. values = [4, 1, 4, 2]gives[True, True, False, True]
  2. values = [3, 1, 2]gives[True, True, True]

Solving it in the practice book needs an active paid plan.

Open it in the practice book
One thought at a time.