Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
Flowers bloom on the days [1, 10, 3, 10, 2]. You need to make 2 bouquets, each from 2 adjacent bloomed flowers (flowers may only be used once). What is the minimum day on which this is possible?
- A. 10
- B. 11
- C. 9
- D. 3
Correct answer: A. 10
Binary search on the day with a linear feasibility check that counts adjacent bloomed runs of length k, resetting the run after each bouquet. Before day 10 the bloomed flowers sit at positions 0, 2 and 4, which are never adjacent; at day 10 the pairs (0,1) and (2,3) both bloom.
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
- In the binary array [1, 1, 0, 1, 1, 1, 0, 1, 1], you may flip exactly one 0 to 1 (or flip none). What is the length of the longest run of…
- How many index pairs i < j in [4, 9, 1, 7, 3, 8, 2] have a sum s with 6 <= s <= 10?
- How many contiguous subarrays of [10, 5, 2, 6] have a product strictly less than 100?
- Greedy removal: scanning "aabaacaab" left to right, you delete any 'a' that immediately follows another 'a' in the current output. How…
- Remove exactly 2 digits from "7419" (keeping order) to make the largest possible number. What is the result?
- Using the Z-function on "ab#abababcab", how many occurrences of the pattern "ab" are found in the text "abababcab"?