Data Structures & AlgorithmsHardGATE CS · TCS NQT
What is the minimum number of characters that must be inserted anywhere in the string abcbd to make it a palindrome?
- A. 3
- B. 2
- C. 1
- D. 4
Correct answer: B. 2
The minimum insertions equal n minus the length of the longest palindromic subsequence. Here the longest is bcb (length 3).
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 non-empty substrings does the string ababa have?
- What is the length of the longest substring of abcabcbbxyzw that contains no repeated character?
- What is the length of the shortest substring of aabdecbcaeb that contains every character of abc (with multiplicity: at least one of each…
- For the string bcabca, let a rotation be the string obtained by moving a prefix of some length to the end. If rotations are indexed from 0…
- How many occurrences of the pattern aba are found in the string abababa when occurrences may overlap?
- What is the length of the longest palindromic subsequence of the word character?