Basic Pattern Question In Leetcode Problem