Data Structures & AlgorithmsVery hardCodeforces Div2 C · TCS NQT
What is the minimum number of characters you must DELETE from "aabbbccddddeee" so that every letter that remains appears the same number of times?
- A. 4
- B. 6
- C. 9
- D. 5
Correct answer: A. 4
Try every common target frequency t: letters with count at least t are reduced to t, and letters with count below t must be removed entirely. Take the minimum deletions over all t. Reducing every letter to the smallest count is a common wrong target.
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
- A rod of length 17 must be cut into pieces each of length at most 5. What is the minimum number of cuts?
- What is the maximum number of DISJOINT non-empty contiguous subarrays of [1, -1, 2, -2, 3, 4, -7, 5, -5, 6] that each have sum 0?
- What is the minimum possible length of a single CONTIGUOUS block of [1, 3, 7, 4, 2, 5, 9] that you can delete (the rest is concatenated in…
- The sorted numbers [1, 3, 6, 7, 10, 11, 15] must be split into the fewest CONTIGUOUS groups so that in each group the largest minus the…
- How many arrays of length 3 with entries from {1, 2, ..., 3} have a maximum entry of exactly 2?
- How many non-empty subsets of [4, 6, 9, 10, 15] (chosen by position) have a greatest common divisor equal to 1?