Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
For "aabaabaa", how many indices i >= 1 have Z-function value exactly 2?
- A. 2
- B. 3
- C. 4
- D. 1
Correct answer: D. 1
Compute the Z-array with the standard linear algorithm and count entries equal to 2. Entries of 1 and 0 are separate counts.
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 ordered pairs (a, b) of integers with a >= 2 and b >= 2 satisfy a b = 36?
- Moving one unit per step, what is the minimum total number of unit moves to make every element of [1, 2, 9, 10, 12] equal to a common…
- How many index triples i < j < k in [1, 2, 3, 4, 5, 6] satisfy a[i] + a[k] = 2 a[j]?
- What is the area of the largest rectangle under the histogram [3, 1, 3, 2, 2]?
- How many distinct XOR values arise from index pairs i < j of [1, 2, 3, 4]?
- How many non-empty prefixes of "abacaba" are palindromes?