Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the minimum number of characters that must be deleted from "abcbdab" to make it a palindrome?
- A. 3
- B. 5
- C. 1
- D. 2
Correct answer: D. 2
Deletions needed equal n minus the longest palindromic subsequence, found by interval DP. Reporting the palindrome length itself answers a different question.
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 pairs of non-overlapping equal substrings of length 2 exist in "abababab" (positions i < j with j >= i + 2)?
- In the text "aaabaaaabaaa", count the occurrences of "aaa" whose starting index is a prime number (0-indexed).
- What is the sum over all adjacent pairs of [4, 2, 5, 1, 3] of the smaller of the two values?
- A shop has a 'buy 2, get the cheapest of the three free' deal. Items priced [3, 1, 4, 2, 5, 6] are bought in groups of three, with the…
- A circular list holds 1..10. Starting at 1, you count 4 nodes (including the current one) and delete the fourth, then continue counting…
- Buildings of heights [3, 7, 8, 3, 6, 1] are viewed from the left. How many buildings are visible (a building is visible if it is strictly…