Greedy with linked list