Leetcode Question 2 Explanation