Solve "remove element" problem in leetcode, scan from two ends and swap non target element with target element.