Company: visa_9oct
Difficulty: medium
Nearly Regular Crosses Problem Description For a rectangular matrix of integers, a cross is a figure formed by joining one row and one column. A cross is considered to be regular if all the elements in it are equal. A cross is called nearly regular if all of its elements are equal except for, at most, one element. The element in the intersection of the row and the column which form the cross. You are given a rectangular matrix of integers matrix . Your task is to return the number of nearly regular crosses within matrix . Note: that by definition the regular cross is also considered to be a nearly regular cross. Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(matrix.length * matrix[0].length * (matrix.length + matrix[0].length)) will fit within the execution time limit. Examples Example 1: Input: matrix = [ [1, 1, 1], [1, 1, 1], [2, 3, 1], [1, 1, 0], [1, 4, 1] ] Output: 2 Explanation: The only two nearly regular cros