1.

In which of the following cases, the maximum sum rectangle is the 2D matrix itself?(a) When all the elements are negative(b) When all the elements are positive(c) When some elements are positive and some negative(d) When diagonal elements are positive and rest are negativeThe question was asked during an online interview.My doubt is from Maximum Sum Rectangle in a 2D Matrix topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Right choice is (a) When all the elements are negative

To explain: When all the elements of a MATRIX are positive, the MAXIMUM sum RECTANGLE is the 2D matrix itself.



Discussion

No Comment Found

Related InterviewSolutions