Capital OneOA #1
Newspaper Page Layout — Multi-paragraph Justification
估计中等评测数据准备中,可先阅读题面
考点(AI 标注)字符串模拟/实现
You are moderating a newspaper page, and you have to align the text on the page properly. The text is provided to you in the following format:
paragraphsis an array of paragraphs, where each paragraph is represented as an array of words.alignsis an array representing the alignment of each paragraph fromparagraphs— each element is either"LEFT"or"RIGHT".widthrepresents the maximum number of characters each line of the output can include.
For each paragraph, include all the words paragraphs[i][j], in order, separated by spaces:
- Include as many words as possible per page line (the length of the line must be less than or equal to
width), and put the next word on a new line if it would exceed this limit. - In the case of excess whitespace, words from
paragraphs[i]should be aligned according toaligns[i]. Ifaligns[i] = "LEFT", the line should have no leading spaces. - Include a border of
'*'characters around all the edges of the result.