📘
Sequence Padder
Given multiple sequences of integers (one per line), pad all sequences to the length of the longest sequence by appending zeros at the end.
Input format:
- Line 1: Number of sequences n
- Next n lines: Space-separated integers
Output: Each padded sequence as a list.
Example:
Input:
3 1 2 3 4 5 6
Output:
[1, 2, 3] [4, 5, 0] [6, 0, 0]
Reasoning:
Step 1: Find max length Lengths: 3, 2, 1 → max = 3
Step 2: Pad each sequence to length 3 [1, 2, 3] → already length 3 [4, 5] → [4, 5, 0] [6] → [6, 0, 0]
Constraints:
- 1 ≤ n ≤ 10
- Sequences can have different lengths
- Pad with 0 at the end (post-padding)
- Output each sequence as a Python list
Editor
Python 3.13.1
Test Results
0/0Run code to see test results.