Code RoomSort linked list
HardPrep Room Coding #155

Sort linked list

CodingAlgorithms & data structuresSenior–Staff~35 min

Sort a singly linked list in ascending order, given as a Python list of integers, and return the sorted sequence as a Python list. You are expected to design an O(n log n) approach appropriate to a linked list (i.e. merge sort, not a comparison sort that needs random access). The list has 0 to 5*10^4 nodes and values fit in 32-bit signed range.

Implement
sort_linked_list(values: list[int]) → list[int]
Examples
in[[4,2,1,3]]out[1,2,3,4]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 35 min
InputExpectedGot
[[4,2,1,3]][1,2,3,4]not run yetsample