Data Structures & AlgorithmsVery hardICPC regional · matrix DP

Problem: What is the time complexity of Kadane's algorithm extended to 2D (maximum-sum submatrix) with an n x n matrix?

  1. A. O(n^3)
  2. B. O(n)
  3. C. O(n^2)
  4. D. O(n^4)

Correct answer: A. O(n^3)

Fixing a pair of rows and running 1D Kadane over the column sums gives O(n^2) pairs times O(n) per pair, which is O(n^3).

More Coding Interview Problems questions

Exams that ask this topic