Count the Number of Ideal Arrays | Leetcode 2338