rewrite leetcode remove element