Hex Dump Formatter
Updated
Problem statement
Given an array bytes of byte values and a positive row width bytesPerRow, return a formatted hexadecimal dump as an array of rows.
Each row has this exact structure:
- an eight-character lowercase hexadecimal offset for the row's first byte;
- two spaces;
bytesPerRowuppercase two-digit hexadecimal slots separated by one space, with missing slots in the final row filled by spaces;- two spaces;
- an ASCII column surrounded by
|characters.
In the ASCII column, byte values from 0x20 through 0x7E use their ASCII character. Every other byte uses .. Return an empty array when bytes is empty.
Function
formatHexDump(bytes: int[], bytesPerRow: int) → String[]Examples
Example 1
bytes = [72,101,108,108,111,0,35,255]bytesPerRow = 4return = ["00000000 48 65 6C 6C |Hell|","00000004 6F 00 23 FF |o.#.|"]The first row contains four printable bytes. In the second row, 0x00 and 0xFF become ., while 0x23 becomes #.
Example 2
bytes = [65,66,67]bytesPerRow = 4return = ["00000000 41 42 43 |ABC|"]The final hexadecimal slot is blank, but the ASCII column contains only the three present bytes.
Constraints
0 <= bytes.length <= 10^50 <= bytes[i] <= 2551 <= bytesPerRow <= 32
More Waymo interview questions
- Linked Perception HistoryONSITE INTERVIEW · Seen Sep 2026
- Dictionary Matches from Repeated LettersONSITE INTERVIEW · Seen Sep 2026
- Cyclic Fuel Command SimulationONSITE INTERVIEW · Seen Sep 2026
- Shortest Travel Time in a Grid with Traffic LightsPHONE SCREEN · Seen Nov 2026
- Fixed-Order Task Run Time With CooldownPHONE SCREEN · Seen Oct 2026
- Reorderable Task Scheduler With CooldownPHONE SCREEN · Seen Oct 2026
- Island Area and Water BoundaryPHONE SCREEN · Seen Sep 2026
- Vehicle Maintenance Event ReadinessPHONE SCREEN · Seen Sep 2026
- Obstacle-Aware Return to OriginPHONE SCREEN · Seen Sep 2026
- Shortest Paths to Multiple TargetsPHONE SCREEN · Seen Sep 2026
Similar questions at other companies
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Digit-Coded Card ValidationCapital One · ONSITE INTERVIEWCapital One interview questions
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Path Leaf Character IteratorGoogle · ONSITE INTERVIEWGoogle interview questions
- Trace Events from Stable Whole-Stack StatesAnthropic · ONSITE INTERVIEWAnthropic interview questions
- Cipher Cover Interval EditingDatabricks · ONSITE INTERVIEWDatabricks interview questions
- Most Frequent Call Path in Interleaved LogsRoblox · ONSITE INTERVIEWRoblox interview questions
- Parse Command-Line TokensSamsara · ONSITE INTERVIEWSamsara interview questions
- Rich-Text Segment Normalization and Bold ToggleScale AI · ONSITE INTERVIEWScale AI interview questions
- Deterministic Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions