Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
How many pairs of non-overlapping equal substrings of length 2 exist in "abababab" (positions i < j with j >= i + 2)?
- A. 9
- B. 10
- C. 8
- D. 2
Correct answer: A. 9
Count position pairs whose length-2 substrings match and whose intervals do not overlap (j >= i + 2). Overlapping matches like positions 0 and 1 are excluded by that condition.
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 text "aaabaaaabaaa", count the occurrences of "aaa" whose starting index is a prime number (0-indexed).
- What is the sum over all adjacent pairs of [4, 2, 5, 1, 3] of the smaller of the two values?
- A shop has a 'buy 2, get the cheapest of the three free' deal. Items priced [3, 1, 4, 2, 5, 6] are bought in groups of three, with the…
- A circular list holds 1..10. Starting at 1, you count 4 nodes (including the current one) and delete the fourth, then continue counting…
- Buildings of heights [3, 7, 8, 3, 6, 1] are viewed from the left. How many buildings are visible (a building is visible if it is strictly…
- Evaluate the postfix expression "3 4 min 5 max 2 +" where min and max take two operands and return the smaller or larger.