Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
What is the minimum number of elements of [1, 3, 2, 5, 4, 6] that must be changed (values may be set arbitrarily) so that the array becomes strictly increasing?
- A. 2
- B. 3
- C. 1
- D. 4
Correct answer: A. 2
Unchanged elements must form a strictly increasing subsequence; the longest one here has length 4 (for example 1, 2, 4, 6), so 2 changes are needed.
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
- How many trailing zeros does 25! have?
- How many index pairs i < j of [1, 2, 3, 4, 5, 6] have a product strictly less than 20?
- Evaluate the postfix expression "2 3 4 + 5 -".
- What is the length of the longest substring of "aabbaacc" in which every letter appears at most twice?
- What is the sum of the integers from 1 to 100 inclusive that are not perfect squares?
- Sum the largest power of two that divides each element of [12, 40, 7, 24]. What is the total?