Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
How many windows of length 3 in [1, 2, 1, 2, 3, 3, 1] contain exactly two distinct values?
- A. 5
- B. 3
- C. 6
- D. 4
Correct answer: D. 4
A fixed window of size 3 with exactly two distinct values has one repeated value among its three entries. Windows with three distinct values or one repeated constant value are not counted.
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
- What is the floor of the square root of the sum of [1000, 2500, 900]?
- How many indices i in "xyzxyzxyz" satisfy s[i] = s[i + 3]?
- A singly linked list holds 1..7. Using the slow/fast pointer method, the slow pointer reaches the middle node. How many nodes come after…
- 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?
- 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?