Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional
Greedy removal: scanning "aabaacaab" left to right, you delete any 'a' that immediately follows another 'a' in the current output. How many characters are deleted?
- A. 3
- B. 4
- C. 2
- D. 6
Correct answer: A. 3
A single pass keeping an output stack and dropping repeats gives the number of deletions. Deleting every second 'a' globally gives the same count only by coincidence here.
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
- Remove exactly 2 digits from "7419" (keeping order) to make the largest possible number. What is the result?
- Using the Z-function on "ab#abababcab", how many occurrences of the pattern "ab" are found in the text "abababcab"?
- For "abacabad", how many indices i (0-indexed) have prefix-function value pi[i] equal to 0?
- For the string "abcdeca", take all length-2 substrings and hash each with h(xy) = (ord(x) + 2ord(y)) mod 5. How many index pairs i < j of…
- How many integers from 1 to 100 inclusive have exactly two 1-bits in their binary representation?
- What is the XOR of the elements at indices 2 through 6 (inclusive) of [5, 8, 1, 9, 4, 3, 7, 2]?