Data Structures & AlgorithmsVery hardGATE CS · TCS NQT
The histogram heights [1, 3, 3, 2, 3] describe bars of width 1. What is the area of the largest rectangle that fits under the histogram?
- A. 9
- B. 8
- C. 6
- D. 12
Correct answer: B. 8
The height-2 rectangle spanning indices 1 to 4 has width 4 and area 8, which beats every other rectangle; the height-1 rectangle over all five bars has area 5.
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 integers from 1 to 50 inclusive have exactly two 1-bits in binary and are even?
- Under the hash h(s) = sum of the character codes of s, how many of the 3-letter strings "abc", "cab", "bac", "xyz", "zyx" share their hash…
- In 3 1 4 4 5 2 6 6 7, an element is a RECORD if it is strictly larger than every element before it (the first element is not counted). How…
- From the array 1 5 3 3 3 7 2 4 6, choose the largest number of PAIRS of positions so that every position is used in at most one pair and…
- What is the length of the longest contiguous subarray of 1 2 1 3 3 2 2 4 4 4 4 1 in which EVERY distinct value appears an even number of…
- Using only swaps of ADJACENT characters, what is the minimum number of swaps needed to turn the string "abcab" into a palindrome?