We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Flipping the Matrix
Flipping the Matrix
Sort by
recency
|
264 Discussions
|
Please Login in order to post a comment
Java 8
No need to flip the matrix, each cell in the top quad will have only few possible options. For example, (0,0) can have (3,0), (0,3),(3,3) cells at its place when matrix is flipped. The formula for finding the possible cell values at this particular cell is
All you have to do is, check max of all possible values at top quad for each cell. Top quad cells for 4x4 matrix is 00, 01, 10, 11 for 6x6, it will 00,01,02,10,11,12 and so on. below is the python solution that passes all tests
Solution with explanation in Python 3:
python
For something different, here's a parallelizable solution for Java 17.