Reverse Linked List in K groups, Accepted version