Data Structures & AlgorithmsModerateTCS NQT · Infosys
Sorted arrays [2, 6, 9, 14] and [4, 7, 11, 15] are merged into one list. How many elements of the merged list lie strictly between 5 and 12?
- A. 5
- B. 4
- C. 3
- D. 6
Correct answer: B. 4
Merging preserves all eight values, so the answer is a count over the merged sorted list. Bounds are strict, so the values 5 and 12 are excluded even though they are not in the list.
More Coding Interview Problems questions
- Choose a from {6, 9, 12} and b from {3, 5, 10}. What is the largest possible value of a XOR b?
- Tasks AAABBC must be scheduled one per time unit; two identical tasks need at least 2 idle-free units between them (cooldown k = 2, i.e…
- Half-open intervals [1,5), [3,8), [10,12), [11,15). How many integer points lie in at least one of these intervals?
- Array [5, -5, 2, 3, -2, 7, 3]. How many contiguous subarrays have a sum that is 0, 5 or 10?
- Sorted positive array [1, 3, 4, 6, 9, 12]. How many index pairs i < j have a[i] a[j] >= 18?
- How many integers x with 1 <= x <= 64 have a binary representation (without leading zeros) that reads the same forwards and backwards?