Data Structures & AlgorithmsHardGATE CS · TCS NQT
How many palindromic substrings of length at least 2 does abcbaccab contain (counted by position)?
- A. 6
- B. 7
- C. 9
- D. 5
Correct answer: D. 5
The palindromes of length 2 or more are bcb, cc, abcba, acca and baccab, so the count is 5. Expanding around each centre finds them all.
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 distinct substrings of length 3 of abcabcabc occur at least twice in the string?
- How many ways can the digit string 226 be decoded when 1 to 26 map to A to Z?
- What is the length of the longest substring of banana that appears at least twice in the string (occurrences may overlap)?
- Evaluate the Reverse Polish expression 10 6 9 3 + -11 / 17 + 5 +. What is the result?
- How many integers x in [1, 1000] have exactly 4 positive divisors?
- How many integers n with 1 <= n <= 200 have exactly 6 trailing zeros in n! (written in base 10)?