Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: What is the minimum number of character replacements needed to make "abcdba" a palindrome?
- A. 2
- B. 1
- C. 0
- D. 3
Correct answer: B. 1
Each mismatched mirror pair needs exactly one replacement, and matched pairs need none. The mirror pairs here are (a,a), (b,b) and (c,d), so the answer is one.
More Coding Interview Problems questions
- Problem: In how many ways can 100 be made using coins 1, 5, 10, 25 (order does not matter)?
- Problem: How many binary strings of length 5 contain no three consecutive 1s?
- Problem: Stock trading allows unlimited transactions, but after selling you must wait one day before buying (cooldown). Prices are [1, 2…
- Problem: Josephus with step 3: 10 people numbered 1 to 10 stand in a circle. Starting from person 1, count 3 people and eliminate the…
- Problem: The sequence x0 = 1 and x(n+1) = (3·x(n) + 1) mod 7 is generated. The first repeated value appears at some step. What is the…
- Problem: A ball starts at position 0 on a track from 0 to 10 and moves 3 units per second. At each boundary it reverses direction…