solve reverse-nodes-in-k-group