1.

Consider the 2×2 matrix {{-1,-2},{-3,-4}}. What is the sum of elements of the maximum sum rectangle?(a) 0(b) -1(c) -7(d) -12I got this question during an interview.My doubt is from Maximum Sum Rectangle in a 2D Matrix topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct option is (b) -1

The explanation is: Since all the ELEMENTS of the 2×2 matrix are NEGATIVE, the maximum SUM rectangle is {-1}, a 1×1 matrix containing the largest element. The sum of elements of the maximum sum rectangle is -1.



Discussion

No Comment Found

Related InterviewSolutions