Data Structures & AlgorithmsHardTCS NQT · Accenture
How many distinct substrings of length 3 does the string abcabcabd have?
- A. 5
- B. 3
- C. 6
- D. 4
Correct answer: D. 4
Enumerate the seven windows of length 3, then count distinct strings. Repeated windows such as abc must be counted once.
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 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…
- How many index pairs i < j in the array [1, 2, 3, 1, 2, 3] make a[i] a[j] = 6?
- How many contiguous subarrays of [2, -2, 3, 1, -4, 2, -1] have sum 0?