Count Items Matching A Rule Leetcode Solution