Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: From the list of integers [10, 15, 20, 25, 30], remove the elements that are divisible by 4 or by 6 (the rest remain in order). What is the sum of the remaining elements?
- A. 50
- B. 100
- C. 80
- D. 70
Correct answer: A. 50
20 (by 4) and 30 (by 6) are removed, leaving 10 + 15 + 25 = 50. Removing only those divisible by both (none) gives 100, removing only multiples of 4 gives 80, and only multiples of 6 gives 70.
More Coding Interview Problems questions
- Problem: The number 1729 is written in base 10. What is the sum of its digits in base 12, given as the digit sum of 1729 written in base 12?
- Problem: A sorted list has values 3, 7, 7, 9, 12, 12, 12, 15. How many distinct values lie within the range [7, 12] inclusive?
- Problem: On a 3×3 grid, each cell is labelled with its row times column (1-indexed). The number of cells whose label is a perfect square…
- Problem: How many integers in [1, 100] have exactly 3 divisors? Run the code. python print(sum(1 for x in range(1, 101) if sum(1 for d in…
- Problem: What is the sum of the digits of 3^20? Run the code. python print(sum(int(c) for c in str(3 20))) What is printed?
- Problem: How many paths of length 3 exist in a complete graph K4 that start and end at different vertices? Run the code (count ordered…