Reorder Data in Log Files
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Each string in logs is a log line: an **identifier** followed by one or more space-separated words. Every word after the identifier is made entirely of lowercase letters (a **letter-log**) or entirely of digits (a **digit-log**). Identifiers are alphanumeric.
Reorder the logs so that:
- all letter-logs come before all digit-logs;
- letter-logs are sorted by their content (everything after the identifier) as plain strings, and logs with identical content are ordered by identifier;
- digit-logs keep their original relative order.
Return the reordered list.
Examples
Constraints
- 1 <= logs.length <= 100
- 3 <= logs[i].length <= 100
- Tokens are separated by single spaces with no leading or trailing spaces
- Each log has an identifier and at least one word after it
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.