Premium problem124. Padding Mask from Sequence Lengths

Easy Locked

Return the (B, T) boolean array that is True at position [i, j] exactly when j < lengths[i]:

  • lengths is a 1-D integer array of B sequence lengths
  • T is the maximum length

Input

lengths = [1 3 2]
T = 4

Output

[[ True False False False]
 [ True  True  True False]
 [ True  True False False]]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)