Data Structures & AlgorithmsVery hardTCS NQT · Infosys
How many times does the pattern aba occur in ababababa when occurrences may overlap?
- A. 3
- B. 4
- C. 5
- D. 6
Correct answer: B. 4
Overlapping occurrences start at every index where the pattern matches, so the count is the number of valid start positions 0 to 6 that match.
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
- For the string aabaaabaa, what is the sum of the Z-function values Z[1] + Z[2] + ... + Z[n-1] (Z[i] is the longest common prefix of the…
- How many distinct substrings of length 3 does the string abcabcabd have?
- How many substrings of abcabcbb contain no repeated character?
- Evaluate the postfix (reverse Polish) expression 5 1 2 + 4 + 3 -. What is the value?
- Array [5, 2, 8, 1, 9, 3] is processed in one left-to-right pass: each node is deleted if its value is strictly greater than the value of…
- A singly linked list holds 1, 2, 3, 4, 5, 6, 7. Adjacent pairs are swapped in one pass (node 1 with 2, node 3 with 4, and so on; an…