Given an m x n 2d grid map of '1's and '0's, print the coordinates of rectangles . Rectangles are formed by 1s
question 1 Find the rectangle coordinates and
question 2 : irregular polygon coordinates. i.e. not having right angles in any of the four sides, and could have many sides in edge case, in many sides case return top leftmost, bottom leftmost, top rightmost and bottom rightmost.
Example 1:
Input: grid = [
["1","1","0","1","0"],
["1","1","0","1","0"],
["1","1","0","0","0"],
["0","0","0","0","0"]
]
q1 : Output: [ [[0,0], [2,0],[0,1],[2,1]] , [[0,3],[1,3]] ]
q2: Output: [ ]
Input: grid = [
["0","1","1","1","1"],
["1","1","1","1","0"],
["0","0","0","0","0"],
["0","0","0","0","0"]
]
q1: output : []
q2: output: [ [[0,1],[1,0],[0,4],[1,3]] ]