← Questions

Left-justify text to a fixed width

0
PikaCodingLast asked Sep 2025

A coding interview question asked in Pika's online assessment, last asked Sep 2025. It tests strings, greedy and simulation.

Given a list of words and a line width W, lay the words out in lines of exactly W characters. Put as many words on each line as fit, in order, with one space between neighbours, and fill the rest of the line with spaces after the last word.

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

What it tests

strings · greedy · simulation

Your code and the AI tutor open when you unlock this question.