Previous question · 1234
Time Based Key Store
mediumData Engineering
Next question · 1236
Minimum Delay Between Events
hardDatabase
Random coding question

1235. Sequence padding and truncation

easy
GeneralGeneral
senior
Function contract
Inputs
seqs
list
max_len
int
padding
str
pad_value
int
truncating
str
Returns
value
np.ndarray

Examples

Input
{
  "seqs": [
    [
      5,
      2,
      9
    ],
    [
      1,
      2
    ],
    [
      7,
      8,
      9,
      10,
      11
    ]
  ],
  "max_len": 4,
  "padding": "post",
  "pad_value": 0,
  "truncating": "pre"
}
Output
[
  [
    5,
    2,
    9,
    0
  ],
  [
    1,
    2,
    0,
    0
  ],
  [
    8,
    9,
    10,
    11
  ]
]

Constraints

Hint 1
Hint 2
Hint 3
Roles
ML Engineer
AI Engineer
Data Scientist
Research Scientist
Companies
GeneralGeneral
Levels
senior
entry
Tags
sequence-padding
truncation
numpy

Similar Questions

Linear Regressionmedium
ML Coding
Activation function relueasy
ML Coding
Text normalizationmedium
ML Coding
41 people are solving this problem
Loading editor for the selected language
Ln 1, Col 1
Program Output
DATAINTERVIEW
Interactive coding terminal
Python / NumPy environment ready.
Type a command below or run code from the editor.
run scriptExecute the current editor contents
submitGrade the current editor contents against all solution test cases
python ("print hello world")Run an isolated Python command
helpShow all available commands