Data Structures & AlgorithmsModerateTCS NQT · SSC CGL Tier 2
Problem: How many composite numbers lie in the range 2 to 50 (inclusive)?
- A. 35
- B. 15
- C. 34
- D. 33
Correct answer: C. 34
2..50 holds 49 numbers, 15 of them prime, so 34 are composite. Counting 1 as composite gives 35, 15 is the prime count, and stopping at 49 gives 33.
More Coding Interview Problems questions
- Problem: How many integers x with 0 ≤ x ≤ 99 satisfy x³ ≡ x (mod 7)?
- Problem: Daily temperatures are [73, 74, 75, 71, 69, 72, 76, 73]. For each day, the wait is the number of days until a strictly warmer day…
- Problem: In the binary array [1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1] at most 2 zeros may be flipped to 1. What is the length of the longest run…
- Problem: Starting from the empty set, a process inserts the numbers 5, 3, 8, 1, 4, 7 into a binary search tree, and then deletes nothing…
- Problem: The array [4, 2, 5, 1, 3] is turned into a max-heap by sift-down from the last parent to the root (standard heapify, 0-indexed)…
- Problem: A string is "racecar" and we ask: how many substrings of length 2 or 3 are palindromes (counted by index ranges)?