Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: A monotone sequence is built: start with 1, and append the next number as (previous number) + (number of digits of previous number). The sequence is 1, 2, 3, ... with this rule. After 6 steps (starting from 1), what is the value?
- A. 6
- B. 28
- C. 7
- D. 64
Correct answer: C. 7
All values stay single-digit, so each step adds 1: 1 → 2 → … → 7 after 6 steps. Counting the start as a step gives 6, adding the digit sum instead of the digit count gives 1, 2, 4, 8, 16, 23, 28, and plain doubling gives 64.
More Coding Interview Problems questions
- 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?
- Problem: The array [5, 3, 8, 6, 2, 7] is processed by the partition step of quicksort with pivot = first element (5), using the…
- Problem: Starting with the number 100, subtract the square of the smallest prime factor of the current number each step (the number is…
- Problem: The string "xyzxyzxyz" is split into 3 equal blocks of length 3. The blocks are compared: how many pairs of blocks (i < j) are…
- 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)…