Data Structures & AlgorithmsHardGATE CS · ICPC regional
What is the largest rectangular area in a histogram with bar heights 6, 2, 5, 4, 5, 1, 6 (each bar has width 1)?
- A. 12
- B. 13
- C. 15
- D. 18
Correct answer: A. 12
The best rectangle uses the three middle bars 5, 4, 5 at height 4, giving 12. Bars of height 6 at the ends only give 6 alone.
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
- In the undirected graph with edges (1,2), (1,3), (2,4), (3,4), (4,5), (3,6), how many vertices are at shortest-path distance exactly 2…
- What is the minimum number of knight moves needed to go from square (0, 0) to (3, 3) on an 8 by 8 board (coordinates 0 to 7)?
- Two sorted linked lists are [1, 5, 9, 12] and [2, 3, 8]. They are merged into one sorted list. What is the 5th value of the merged list…
- In the array [2, 8, 5, 5, 3, 7, 5], how many index pairs i < j have a[i] + a[j] = 10?
- How many distinct sums are obtained by contiguous non-empty subarrays of [1, -1, 2, -2]?
- What is the length of the longest substring of aabbcaabcc in which every character occurs at least twice?