leetcode reverse nodes in k group refactoring