rewrite leetcode partition list