FastPrepRender Wrapped Two-Party Chat Lines
Problems/Render Wrapped Two-Party Chat Lines

Render Wrapped Two-Party Chat Lines

ZipRecruiter logoZipRecruiter● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes text tagged by sender, wrapping to a user width, fixed-width output, and opposite left and right alignment for two senders. We supplied wrapping by characters, literal spaces, empty messages, and padding with spaces. Our version is about 83% the same as the reported question.

Each message is [sender, text], where sender is 1 or 2. Split text into consecutive character chunks of at most contentWidth; preserve every character, including spaces. An empty text produces one empty chunk.

Pad every chunk with spaces to exactly totalWidth: sender 1 is left-aligned and sender 2 is right-aligned. Return all rendered lines in message order.

Function

renderChat(messages: String[][], contentWidth: int, totalWidth: int) → String[]

Examples

Example 1

messages = [["1","hello"],["2","world"]]contentWidth = 5totalWidth = 8return = ["hello   ","   world"]

The same-width texts align to opposite sides.

Example 2

messages = [["1","abcdef"]]contentWidth = 3totalWidth = 5return = ["abc  ","def  "]

Text is divided into consecutive chunks.

Constraints

  • 1 <= contentWidth <= totalWidth <= 1000
  • The total message text length is at most 100000.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Branch with the Most FilesCapital One · OACapital One interview questions
  • Robot Stops Left or Right (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • REST API: Highest International StudentsRippling · OARippling interview questions
  • Rearrange String by Alternating EndsHudson River Trading · OAHudson River Trading interview questions
  • Filter Isolated Interior Signal BitsSEDEMAC · OA
  • Scale Ingredient QuantitiesUpstart · OAUpstart interview questions
  • Telephone Keypad String EncodingEpic · OAEpic interview questions
  • Count Invalid Log GroupsIBM · OAIBM interview questions
  • Count Case-Insensitive TripletsTikTok · OATikTok interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public String[] renderChat(String[][] messages, int contentWidth, int totalWidth) {
        // Write your code here.
    }

}
Checking account…