Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the minimum number of elements to delete from [1, 1, 1, 2, 2, 2, 2, 3] so that every value appears at most twice?
- A. 4
- B. 2
- C. 5
- D. 3
Correct answer: D. 3
Each value keeps at most two copies, so the deletions per value are its count minus two when positive. Summing those gives 1 + 2 = 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
- Group the values [1, 2, 4, 5, 6, 9, 10] so that consecutive sorted values with difference at most 1 share a group. How many groups result?
- How many ordered triples of positive integers (x, y, z) satisfy x + y + z = 10?
- Replacing at most one character, what is the length of the longest substring of "abcbbbcaa" that can be made into a single repeated letter?
- What is the smallest integer greater than 13 that has the same number of 1-bits as 13 in binary?
- Convert a(b+c)-d/e to postfix with the shunting-yard algorithm (+ and - have lower precedence than and /; all operators are…
- Evaluate the prefix (Polish) expression - 3 + 2 4 5. What is the value?