Dsa
Sorting
Easy
Log Fragment Stitcher
You are given log entries that arrived out of order. Each entry contains a timestamp (HH:MM), a fragment index, a total fragment count (e.g., '1/3'), and the message. You need to sort logs by time, and then by their fragment sequence to reconstruct the message correctly.
Input Format:
First line: Integer N.
Next N lines: 'HH:MM X/Y Message'
Output Format:
The sorted messages only, one per line.
Example:
Input:
3
12:00 2/2 world
09:00 1/1 start
12:00 1/2 hello
Output:
start
hello
world
Key concepts
data cleaningtuple sorting
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now