Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the minimum number of characters that must be deleted from the binary string "1101001110" so that no two adjacent characters are equal?
- A. 5
- B. 3
- C. 2
- D. 4
Correct answer: D. 4
Deleting one character from each run of equal adjacent characters makes the string alternate, so the cost is the number of adjacent equal pairs. Counting positions of 1 (last option) is unrelated.
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
- People 1 to 10 stand in a circle. Starting from person 1, every second person is eliminated until one remains. Who survives?
- How many unordered pairs {x, y} of distinct integers from 1 to 20 have x + y divisible by 5?
- For "dcbadcba", among its rotations, which starting index i (0-based, the rotation s[i:] + s[:i]) gives the lexicographically smallest…
- What is the maximum nesting depth of parentheses in "(()(()))()"?
- How many distinct values does floor(n / 3) take as n ranges over 1 to 20 inclusive?
- What is the sum of an = n mod 7 for n from 1 to 20 inclusive?