Answer for Leetcode