reverse nodes in k group
with constant memory