Smallest Number Following Pattern Leetcode Premium