Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the area of the largest rectangle under the histogram [3, 1, 3, 2, 2]?
- A. 7
- B. 4
- C. 9
- D. 6
Correct answer: D. 6
Each bar extends left and right while neighbours are at least as tall; the maximum product is the bar of height 2 spanning three bars, giving 6.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many distinct XOR values arise from index pairs i < j of [1, 2, 3, 4]?
- How many non-empty prefixes of "abacaba" are palindromes?
- What is the minimum number of single-character flips needed to turn the binary string "10100101" into a string of the form 0...01...1 (all…
- For [1, -2, 3, 4, -1, 5, -6, 2], you may delete at most one element before taking a maximum sum over non-empty contiguous subarrays. What…
- What is the sum of i j over all pairs 1 <= i < j <= 6?
- How many index triples i < j < k in [2, 3, 5, 7, 8] satisfy a[k] - a[i] <= 4?