FastPrepParse and Store Log Records
Problems/Parse and Store Log Records

Parse and Store Log Records

WhatNot logoWhatNot● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A software-engineer report names parsing and storing logs without a full statement. Our version is about 55% the same as that description. The record format, time ordering, tie behavior, lossless storage, and limits are our assumptions.

Parse the log lines and return their stored records.

For this exercise, each valid line has the form timestamp|level|message with exactly two pipe separators. The timestamp is a nonnegative decimal integer written without leading zeros except for 0. The level is INFO, WARN, or ERROR. The message may be empty and contains no pipe.

Return each record as three strings [timestamp, level, message], sorted by increasing numeric timestamp. Keep equal-time records in their original order. Preserve every duplicate record and the exact message text, including spaces.

Function

parseAndStoreLogs(lines: String[]) → String[][]

Examples

Example 1

lines = ["12|INFO|started","3|ERROR|disk full","12|WARN|retry"]return = [["3","ERROR","disk full"],["12","INFO","started"],["12","WARN","retry"]]

Records sort by numeric timestamp. The two time-12 records retain their original order.

Example 2

lines = ["0|INFO|"]return = [["0","INFO",""]]

An empty message is valid and remains the third field.

Example 3

lines = []return = []

No input records produces an empty stored collection.

Constraints

  • For this exercise, assume 0 <= lines.length <= 100.
  • All lines satisfy the stated input format.
  • Timestamps are between 0 and 10^9.
  • Each message contains at most 100 printable ASCII characters and no pipe.

More WhatNot Onsite Interview questions

  • Merge Sorted Squares of Two ArraysPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Adjacent Pair and Run RemovalPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • User Journey PathsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Search a 2D MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Detect Blocked Chat MessagesPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026
  • Detect Blocked Chat PhrasesPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026
  • Minimum Remove to Make Valid ParenthesesONSITE INTERVIEW · Seen Dec 2024
  • Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2024
  • Merge Two Sorted ListsONSITE INTERVIEW · Seen Jul 2024
  • Number of Submatrices That Sum to TargetONSITE INTERVIEW · Seen Jul 2024

Similar questions at other companies

  • Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
  • Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Response Time Stats by URL PatternGusto · ONSITE INTERVIEWGusto interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Longest Consecutive Login StreakAmazon · ONSITE INTERVIEW
  • Keyboard Autocomplete SuggestionsLyft · ONSITE INTERVIEWLyft interview questions
  • Query JSON Records with WHERE and ORDER BYGitHub · ONSITE INTERVIEW
  • Sort by Odd-Position Digit SumPelatro · ONSITE INTERVIEW
  • Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
  • Serialize and Deserialize a String Key-Value StoreByteDance · ONSITE INTERVIEWByteDance interview questions

Interview reports that mention this question

  • Whatnot interviews · September 2026

WhatNot interview experiences

  • Whatnot OA · 2024
  • Whatnot OA · November 2023
  • Whatnot interviews · November 2023
  • Whatnot interviews · February 2024
  • Whatnot interviews · March 2024
All WhatNot interview questionsSee WhatNot hiring insights
Saved
class Solution {
    public String[][] parseAndStoreLogs(String[] lines) {
        // write your code here
    }
}
Checking account…