solution for remove nth from end.