Number Following A Pattern Leetcode Sql