rewrite leetcode candy