Leetcode Counting Elements In 2d Array