Answer code for leetcode