Data Structures & AlgorithmsVery hardTCS NQT · Accenture
What is the digital root of 98765 (repeatedly sum the digits until one digit remains)?
- A. 9
- B. 8
- C. 10
- D. 12
Correct answer: B. 8
The digit sum is 35, then 8. The digital root equals n mod 9 when n mod 9 is not 0, which gives 98765 mod 9 = 8.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many ways are there to climb exactly 6 stairs taking steps of size 1, 2 or 4 (different orders of steps count as different ways)?
- How many integers x in [1, 200] have x^2 mod 10 equal to 4?
- Five people stand in a circle numbered 1 to 5. Starting from person 1, every third person is removed until one remains. Who survives?
- Gas stations are on a circular route: gas = [1, 2, 3, 4, 5] and the cost to reach the next station = [3, 4, 5, 1, 2]. Starting with an…
- Given a set of intervals, you want the fewest intervals to remove so the rest do not overlap. Which greedy strategy is correct?
- Which data structure answers range-minimum queries and point updates each in O(log n) time?