FastPrepText Justification
Problems/Text Justification

Text Justification

Bloomberg LP logoBloomberg LP● HardNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a firsthand Bloomberg new-grad interview as Word Wrap extended to Text Justification. In our version, you fill each line greedily, and extra spaces go to the left first.

Given an array of non-empty strings words and an integer maxWidth, format the words into lines of exactly maxWidth characters.

Greedily place as many words as possible on each line. For every non-final line containing multiple words, distribute spaces as evenly as possible; when they do not divide evenly, gaps farther left receive one extra space. A non-final line containing one word is padded on the right.

The final line is left-justified with one space between adjacent words and trailing spaces added to reach maxWidth. Return the formatted lines.

Function

fullJustify(words: String[], maxWidth: int) → List<String>

Examples

Example 1

words = ["This", "is", "an", "example", "of", "text", "justification."]maxWidth = 16return = ["This    is    an", "example  of text", "justification.  "]

The greedy grouping produces three lines of exactly 16 characters. Spaces on non-final lines are distributed evenly, while the final line is padded on the right.

Example 2

words = ["What","must","be","acknowledgment","shall","be"]maxWidth = 16return = ["What   must   be", "acknowledgment  ", "shall be        "]

The one-word middle line is padded on the right. The final line uses one space between its words and trailing spaces to reach width 16.

Example 3

words = ["Science","is","what","we","understand","well","enough","to","explain","to","a","computer.","Art","is","everything","else","we","do"]maxWidth = 20return = ["Science  is  what we","understand      well","enough to explain to","a  computer.  Art is","everything  else  we","do                  "]

Each line has exactly 20 characters. Extra spaces on non-final lines are assigned to the leftmost gaps, and the final line is right-padded.

Constraints

  • 1 <= words.length <= 300
  • 1 <= words[i].length <= 20
  • 1 <= maxWidth <= 100
  • words[i].length <= maxWidth
  • Every word contains only English letters and symbols.

More Bloomberg LP Phone Screen questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Text JustificationGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Greedy and Beam Sentence DecodingMicrosoft · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • Remove Duplicate Letters for the Largest ResultAmazon · PHONE SCREEN
  • Text JustificationUber · PHONE SCREENUber interview questions
  • Text JustificationWhatNot · PHONE SCREENWhatNot interview questions
  • Word Wrap with Even JustificationSentry · OA · PHONE SCREENSentry interview questions
  • Match a Pattern With ? and *Adobe · PHONE SCREENAdobe interview questions
  • Lexicographically Largest Distinct-Letter SubsequenceNavan · PHONE SCREENNavan interview questions
  • Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
  • Remove K DigitsProcol · PHONE SCREEN

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public List<String> fullJustify(String[] words, int maxWidth) {
      // write your code here
    }

}
Checking account…