Rectangle in a 2D Array

You are given a two dimensional array containing arrays of integers with some duplicate values as an argument. Return true if a rectangle is formed by four duplicated integers.

Requirements

  • Must return either true or false

Example #1

solve([
  [1, 2, 5, 1, 5, 1],
  [0, 4, 5, 7, 7, 3],
  [1, 6, 7, 1, 7, 8]
])
> true

Rows one and three contain 1's in the same columns which can form a rectangle, so we return true.

Example #2

solve([
  [0, 2, 5, 1, 5, 9],
  [0, 4, 5, 6, 1, 3],
  [5, 6, 7, 1, 7, 8]
])
> false

The are four 5's found in columns three and five and rows two and three, however, they do not form a rectangle, so we return false.