Splits integers into groups using a linked list