reverse and kth last element in an linked list