Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional
How many times does the pattern "ababa" occur in the text "ababcababa", counting overlapping occurrences?
- A. 1
- B. 2
- C. 3
- D. 0
Correct answer: A. 1
Only index 5 matches: at index 0 the text reads ababc and breaks the pattern at its fifth character, so there is one occurrence.
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 palindromic substrings (counting each occurrence by position, length 1 and up included) does "abacaba" contain?
- What is the length of the longest well-formed (balanced) contiguous substring of ")()())"?
- n = 7 people stand in a circle numbered 1 to 7. Starting from person 1, every 3rd remaining person is removed until one remains. Which…
- A linked list holds 1, 2, 3, 4, 5, 6, 7. Reversing each complete group of 3 nodes (leaving a final incomplete group unchanged) gives which…
- How many integers from 1 to 100 inclusive are divisible by at least one of 3, 5 or 7?
- What is the sum of lcm(a, b) over all unordered pairs of distinct positions in [2, 3, 4, 6]?