Odd even linked list
Given a singly linked list as a plain list of values, group all nodes at odd positions together followed by the nodes at even positions, preserving the relative order within each group. Positions are 1-indexed (first node is odd). Return the reordered list of values. The list may be empty.
Implement
odd_even_list(values: list[int]) → list[int]Examples
in
[[1,2,3,4,5]]out[1,3,5,2,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 20 min
solution.py
InputExpectedGot
[[1,2,3,4,5]][1,3,5,2,4]not run yetsample