Data Structures & AlgorithmsModerateSSC CGL Tier 2 · TCS NQT
Problem: For the sequence 2, 3, 5, 7, 11, …, the first 10 prime numbers are listed. What is the sum of the 10th and 7th primes in the list?
- A. 50
- B. 36
- C. 46
- D. 17
Correct answer: C. 46
The 10th prime is 29 and the 7th is 17, so 46. Using 0-based indexes 10 and 7 gives 31 + 19 = 50, shifting both down gives 23 + 13 = 36, and 17 adds the positions.
More Coding Interview Problems questions
- Problem: A bitmask represents a subset of the 4 items {A, B, C, D} by bits 0–3. How many subsets have an even number of items and do NOT…
- Problem: Find the number of ways to select a non-empty subset of {1, 2, 4, 8, 16} whose sum is a multiple of 5.
- Problem: In the array [3, 5, 2, 8, 6, 1], the number of elements that are greater than every element after them (right leaders) is…
- Problem: A monotone sequence is built: start with 1, and append the next number as (previous number) + (number of digits of previous…
- Problem: The numbers 1 to 20 are split into odd numbers and even numbers. What is the absolute difference between the sum of the odd…
- Problem: A string of length 5 uses the letters x, y, z. How many such strings contain each of the three letters at least once?