[Reject] Google SE Phone Screen Question Compress 2D array with minimum value
Anonymous User
922

Given a N x N matrix, output the compressed W x W matrix in a way that each value is the minimum from original W x W sub-matrices. For example, given matrix:
[1 6 3]
[2 5 9]
[3 8 11]
and n = 3, w = 2.
The output should be
[1 3]
[2 5]

Explanation:
First we break the 3 x 3 matrix into 2 x 2 sub matrice:
[1 6] [6 3]
[2 5] [5 9]

[2 5] [5 9]
[3 8] [8 11]
Then take the minimal number from each 2 x 2 blocks.

I could only think of the brute-force approach. I appreciate any thoughts on improving the time complexity. Thanks!

Comments (6)