Data Structures & AlgorithmsHardGATE CS · TCS NQT
What is the number of occurrences of the pattern abab in the string ababababab, counting overlapping matches?
- A. 4
- B. 5
- C. {C-2}
- D. 6
Correct answer: A. 4
Matches start at positions 0, 2, 4 and 6, so the overlapping count is 4. Non-overlapping search would report only 2.
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 binary strings of length 5 contain no two consecutive zeros?
- What is the lexicographically smallest string obtainable from cbad by swapping exactly one pair of characters?
- How many integers x in [1, 100] are divisible by 3 and have a reversed digit string also divisible by 3?
- What is the sum of all divisors of 36 (sigma function)?
- How many unordered pairs {a, b} with 1 <= a < b <= 12 have a + b divisible by 4?
- What is the product of all positive divisors of 36?