Amazon Onsite | Sort linked list in chunks of size K according to sum

You are given a linked list and a number k. You have to sort the linked list in groups of size k by the sum value of each individual chunk in decreasing order. The elements within a chunk will not change.
Example:
Linked List: 1->3->0->5->1->7->0->2->4->3
k=2

Output: 1->7->4->3->0->5->1->3->0->2

Comments (1)