Find a Column in 2D Array of All Ones
You are Given a two dimensional array containing arrays of integers, where each integer is either a 1 or a 0. Return true if any row or column contains only ones, false if not.
Requirements
- Must return either true or false
Example #1
solve([
[0, 1, 1, 0, 0, 1],
[0, 1, 1, 0, 0, 1],
[0, 1, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 1],
[0, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 1, 0]
])
> true
The second column (1st index of all arrays), contains all 1's, so we return true.
Example #2
solve([
[0, 1, 1, 0, 0, 1],
[0, 1, 1, 0, 0, 1],
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 1],
[0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 1, 0]
])
> false
No row or column contains all 1's.
Example #3
solve([
[0, 1, 1, 0, 0, 1],
[0, 1, 1, 0, 0, 1],
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 1, 0]
])
> true
The fourth array (row) contains all 1's, so we return true.