Right-pad variable-length sequences to the length of the longest one. sequences is a list of lists and pad_value (default 0) fills the missing positions.
Implement solve(sequences, pad_value=0).
Returns. Return a tuple (padded, lengths): a 2-D NumPy array of shape (n_sequences, max_length) and an integer array with the original lengths.
Example 1
Input:
solve([[1, 2, 3], [4]], 0)
Output:
([[1, 2, 3], [4, 0, 0]], [3, 1])
Example 2
Input:
solve([[], [7, 8]], -1)
Output:
([[-1, -1], [7, 8]], [0, 2])
No results yet
Run your code to check it against the examples, or submit to run every test.