This is an easy Leetcode 733 problem. See problem description below: CONCEPT To get a clearer picture of what the question wants us to do, first, it will be better to break the multidimensional array elements to form a square-like structure e.g the picture below shows the break down of [[1,1,1]…