Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
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?
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
After sorting, a new group starts whenever the gap exceeds 1. The gaps 2 to 4, 6 to 9 are the breaks, so there are three groups.
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 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?
- How many windows of size 4 in the array [4, 2, 12, 3, 8, 1, 9, 5] have their maximum at the first position of the window (ties with a…