Code Room
CodingEasycod-g1201
Subject ArraysLevel Entry–Mid~11 minCommon in Databases & SQL · Algorithms & data structures interviewsIndustries Software development

Question

A report generator needs every data row to have exactly `size` columns. Given a row of integers, a required size (size >= 0), and a fill value, return the row adjusted to that exact length: if it is too short, append the fill value until it fits; if it is too long, keep only the first `size` entries; if it already fits, return it unchanged. Example: [1, 2] with size 4 and fill 0 becomes [1, 2, 0, 0].

Implement
fit_to_length(row: list[int], size: int, fill: int) → list[int]
Examples
in[[1,2],4,0]out[1,2,0,0]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.