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?
- A. O(n^3)
- B. O(n)
- C. O(n^2)
- 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
- Problem: A hash table uses chaining, and every insertion first scans the key’s chain to make sure the key is not already present. What is…
- Problem: Which problem does the 'LCA by Euler tour and RMQ' reduce to?
- Problem: Which property does a 'matroid intersection' problem violate in general, making it harder than a single matroid?
- Problem: What is the time complexity of finding a minimum spanning tree in a complete graph with V vertices using Prim's algorithm and an…
- Problem: What does Fermat's little theorem let you compute efficiently?
- Problem: Which statement about the Bellman-Ford algorithm is correct when there is a negative cycle reachable from the source?