Question: import java.io.*; import java.util.*; public class Solution { // If you need extra classes, you can define them privately here within class Solution // Prints

import java.io.*; import java.util.*;
public class Solution { // If you need extra classes, you can define them privately here within class Solution
// Prints to standard out. static void reflowLines(int lineLength, List
// DO NOT MODIFY MAIN() public static void main(String[] args) { int arg0 = -1; List
String line; boolean first_arg = true; try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { while ((line = br.readLine()) != null) { if (line.equals("")) { continue; }
if(first_arg) { arg0 = Integer.parseInt(line); first_arg = false; } else { arg1.add(line); } } } catch (IOException e) { e.printStackTrace(); return; }
reflowLines(arg0, arg1); } }
We are building a word processor and we would like to implement a "reflow" functionality that full-justifies text. Given a maximum line width and an array containing lines of text, re-flow the text to fit the new width. Each line should be the exact specified width. If any line is too short, insert - (as stand-ins for spaces) between words as equally as possible until it fits. Example input 12 It was the best of times it was the worst of times Example output It--was--the best------of times-it-was the-worst-of
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
