Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA
What is the minimum number of single-character replacements needed to make "abcdba" a palindrome?
- A. 2
- B. 0
- C. 1
- D. 4
Correct answer: C. 1
Each mirrored pair of positions with different letters needs exactly one replacement, and pairs with equal letters need none. Counting all unequal positions double-counts each pair.
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 well-formed strings of 3 pairs of parentheses (length 6) exist?
- On a line with cells 1 to 10, a lamp at position p lights cells p-2 to p+2. Lamps are placed at positions 1, 4, 6, 9. Do they light every…
- The histogram heights [1, 3, 3, 2, 3] describe bars of width 1. What is the area of the largest rectangle that fits under the histogram?
- How many integers from 1 to 50 inclusive have exactly two 1-bits in binary and are even?
- Under the hash h(s) = sum of the character codes of s, how many of the 3-letter strings "abc", "cab", "bac", "xyz", "zyx" share their hash…
- In 3 1 4 4 5 2 6 6 7, an element is a RECORD if it is strictly larger than every element before it (the first element is not counted). How…