rewrite leetcode remove nth node from the end of list