Data Structures & AlgorithmsHardGATE CS · TCS NQT
How many windows of size 4 in [1, 2, 1, 3, 4, 2, 5, 6] contain four pairwise distinct values?
- A. 5
- B. 4
- C. 1
- D. 6
Correct answer: B. 4
A window is distinct when its set has size 4. Windows containing the repeated 1 or 2 fail, so only some of the five windows qualify.
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 smallest positive integer n such that n! ends in exactly 10 trailing zeros?
- Items [1, 1, 1, 1, 2, 2, 3] must be placed into stacks of capacity 3 such that each stack holds only identical items. What is the minimum…
- How many index pairs i < j in [0, 1, 2, 3, 4] satisfy a[i] + a[j] = a[i] a[j]?
- Repeatedly remove adjacent equal characters from "abbaca" using a stack. How many characters are removed in total?
- How many integers n from 1 to 99 inclusive have both n and n + 1 squarefree (not divisible by any square greater than 1)?
- Choose the fewest intervals of length 3 (covering integer points s, s+1, s+2 for a start s from 1 to 8) so that every integer point from 1…