Data Structures & AlgorithmsVery hardGATE CS · TCS NQT
In the text "abcabdabc", how many positions match the pattern "a?c" where '?' matches any single character?
- A. 3
- B. 2
- C. 1
- D. 0
Correct answer: B. 2
A wildcard match checks each position character by character, treating '?' as a free slot. Exact matching of the literal text "a?c" (last option) finds none, which is a different answer.
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
- Sum, over the queries x = 3, 6, 9 on the sorted array [1, 3, 3, 5, 8, 9, 12], of the number of elements that are less than or equal to x…
- How many index pairs i < j in [1, 3, 5, 7, 9, 15] have a sum that is a power of two?
- From tasks (value, cost) = (5, 4), (6, 2), (3, 1), (7, 5) you may choose any subset whose total cost is at most 7. What is the maximum…
- How many trailing zeros does 2^7 5^4 10 have in decimal?
- What is the number of unmatched '(' characters in the string "(()())(()" after the standard left-to-right matching?
- What is the largest number of distinct characters in any contiguous window of length 4 of "abcbdabca"?