Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: In the sequence 2, 3, 5, 8, 12, 17, … each term increases by one more than the previous increase (differences 1, 2, 3, 4, …). What is the 8th term?
- A. 30
- B. 38
- C. 37
- D. 23
Correct answer: A. 30
Term 8 = 2 + (1 + … + 7) = 30. Adding increments up to 8 gives the 9th term 38, starting increments at 2 gives 37, and stopping at 6 gives the 7th term 23.
More Coding Interview Problems questions
- Problem: How many 4-element subsets of {1, 2, ..., 8} have a sum that is a multiple of 5?
- Problem: The array [4, 9, 16, 25] has its square roots summed. What is the sum of the square roots of these four numbers?
- Problem: A grid has 5 cells in a row, each painted red or blue. How many colourings have no two adjacent cells of the same colour?
- Problem: What is the largest integer n such that n! has at most 3 trailing zeros in base 10?
- Problem: The matrix [[2,0],[0,3]] is raised to the power 4 (matrix power). What is the sum of all entries of the result?
- Problem: A word is "statistics". How many distinct letters appear at least twice in it?