Data Structures & AlgorithmsHardGATE CS · TCS NQT
What is the smallest integer k such that 3k is at least every element of [5, 10, 14, 17]?
- A. 16
- B. 6
- C. 5
- D. 17
Correct answer: B. 6
Only the maximum matters: k = ⌈17/3⌉ = 6, since 3 · 6 = 18 ≥ 17. Floor division gives 5 (and 15 < 17), using the total gives ⌈46/3⌉ = 16, and 17 confuses k with the maximum itself.
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 length of the longest contiguous substring of "bbacbbcab" containing at most one letter 'a'?
- What is the sum of a XOR (a >> 1) over a = 5, 8 and 13 (where >> is a right shift by one bit)?
- How many index pairs i < j in [2, 5, 4, 10, 3, 15] have a product that is a multiple of 10?
- With weight limit 15, what is the maximum number of items from [5, 3, 8, 2, 7, 4] you can carry (choose any subset)?
- How many integers from 1 to 500 inclusive are divisible by 4 but not by 6?
- How many different output orders can a stack produce from the input 1, 2, 3, 4 pushed in order?