Hello, I was asked this question in Tiktok interview. I was not able to solve it. Just wanted some help with this problem.
It's the year 2200 and Tiktok is deciding to build a new office on Mars.
They're not sure where to build it and they want it to be as close to their other offices as possible. We use a matrix to represent the land.
Input: [[0,0,1,0,0],[0,0,0,0,0],[1,0,2,0,1]]
0 - 0 - 1 - 0 - 0
0 - 0 - 0 - 0 - 0
1 - 0 - 2 - 0 - 1
Output: {1,2}
Input: [[0,0,1,2,0],[0,0,0,0,1]]
0 - 0 - 1 - 2 - 0
0 - 0 - 0 - 0 - 1
Output: {1,2} or {1,3}