Basic Pattern Question In Leetcode Solutions