Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA
How many windows of size 3 in [5, 2, 7, 3, 1, 6, 4] have their minimum exactly at the middle position?
- A. 3
- B. 1
- C. 2
- D. 4
Correct answer: C. 2
Check the middle value against the window minimum; each window needs only that comparison. A tie with an endpoint still counts as minimal at the middle when equal.
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
- Five lectures are the half-open intervals [1,2), [2,5), [4,6), [5,8), [7,9). How many lectures can be attended without overlap (touching…
- How many index pairs i < j in "aabb" give a palindromic subsequence of length 2 (that is, s[i] = s[j])?
- How many distinct value pairs (x, y) with x < y satisfy x + y = 10 among the values of [1, 2, 3, 4, 5, 6, 7, 8, 9, 5]?
- Smallest value of the maximum block sum when [4, 8, 2, 9, 3, 6] is split into 3 contiguous blocks?
- Using each of [1, 2, 4, 16] at most once, what is the smallest positive integer that cannot be written as a sum of distinct elements of…
- What is the exponent of 3 in the prime factorisation of 30!?