Leetcode Counting Elements In 2d