Data Structures & AlgorithmsHardAmazon OA · Stacks
What is the area of the largest rectangle in a histogram with bar heights [3, 6, 5, 7, 4, 8, 1, 0, 6] and unit width?
- A. 20
- B. 18
- C. 24
- D. 28
Correct answer: A. 20
The five bars from the 2nd to the 6th all have height at least 4, giving 4 x 5 = 20; the bars 6, 5, 7 alone give only 15.
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
- What is the maximum sum of a non-empty contiguous subarray of [3, -4, 2, -3, -1, 7, -5] if you may delete at most one element from the…
- How many contiguous subarrays of [2, 3, 4, 1, 5, 2, 6] have a product strictly less than 50?
- How many contiguous subarrays of [4, 5, 0, -2, -3, 1] have a sum divisible by 5?
- How many inversions (pairs i < j with a[i] > a[j]) does [8, 4, 2, 1, 7, 3, 6, 5] have?
- Eight trains have arrival times 900, 915, 930, 945, 1000, 1010, 1030, 1100 and departure times (in some order) 930, 1000, 1015, 1000…
- A hash table of size 7 with h(k) = k mod 7 and linear probing holds keys 3, 10, 17, 24 at indices 3, 4, 5, 6. Key 10 is then deleted by…