Circular Pattern Matching Leetcode