Data Structures & AlgorithmsHardProduct Company SDE · divide and conquer
Problem: Which algorithm finds the maximum subarray sum in O(n log n) by splitting the array and handling the crossing case?
- A. Divide and conquer with a maximum crossing subarray
- B. Dijkstra's algorithm
- C. Gale-Shapley
- D. Edmonds' blossom algorithm
Correct answer: A. Divide and conquer with a maximum crossing subarray
The crossing case is solved by extending outward from the midpoint in each half, giving the recurrence T(n) = 2T(n/2) + O(n).
More Coding Interview Problems questions
- Problem: What does the Pisano period of m describe?
- Problem: Which characterisation of bipartite graphs is correct?
- Problem: What does the Erdos-Szekeres theorem state?
- Problem: What does Dilworth's theorem say about a finite partially ordered set?
- Problem: What is the time complexity of range-assign and range-sum queries with a lazy segment tree?
- Problem: What does the two-heap technique compute in a data stream?