Data Structures & AlgorithmsHard
In the array [2, 7, 3, 7, 1, 4], how many contiguous subarrays have their LEFT-most element equal to the maximum of the subarray (ties allowed)?
- A. 9
- B. 12
- C. 11
- D. 13
Correct answer: B. 12
The condition is on the first element only, but it must dominate every other element of the subarray. Requiring a strictly larger value excludes ties, and checking the minimum or the right end measures other properties.
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 contiguous subarrays of [1, 2, 1, 3, 2, 2, 1] have equal first and last elements and length at least 2?
- Counting subarrays whose sum is divisible by k with prefix remainders, which statement is TRUE?
- Two pointers count subarrays of POSITIVE integers with sum at most K. Why can the left pointer only move forward as the right pointer moves?
- When summing the MAXIMUM over all subarrays with repeated values, the standard contribution method uses one strict and one non-strict…
- Which statement about subarrays with XOR equal to 0 is CORRECT?
- A zero-sum subarray counter keeps a map of prefix sums. At each index the current prefix is inserted into the map BEFORE the lookup. What…