Data Structures & AlgorithmsHardAmazon OA · Arrays
A sliding window of size 3 moves over [1, 3, -1, -3, 5, 3, 6, 7]. What is the sum of the window maximums?
- A. 29
- B. 26
- C. 31
- D. 23
Correct answer: A. 29
Window maxima are 3, 3, 5, 5, 6, 7, which sum to 29.
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 length of the longest substring of "abcabcbbxyzab" with no repeated character?
- A singly linked list 1 -> 2 -> ... -> 7 is reversed in groups of k = 2; a final group with fewer than k nodes is left as it is. What is…
- The bars of a histogram-shaped terrain have heights [4, 2, 0, 3, 2, 5]. After rain, how many units of water are trapped between the bars?
- Keys 10, 21, 32, 43, 54 are inserted in this order into an empty table of size 11 using h(k) = k mod 11 and quadratic probing, the i-th…
- The numbers 1, 2, 3, 4, 5, 6 are pushed onto an empty stack in this order, with pops allowed at any time between pushes. Which of the…
- How many contiguous subarrays of [3, 4, 7, 2, -3, 1, 4, 2] have a sum of exactly 7?