Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture
Problem: What is the last non-zero decimal digit of 10! (3628800)?
- A. 0
- B. 3
- C. 2
- D. 8
Correct answer: D. 8
3628800 without its trailing zeros is 36288, which ends in 8. Reading the raw last digit gives 0, 3 is the leading digit, and removing the factors of 5 without their matching 2s gives 10!/25 = 145152, ending in 2.
More Coding Interview Problems questions
- Problem: Five people (including Alice and Bob) stand in a row. In how many arrangements do Alice and Bob stand next to each other?
- Problem: The array [3, 1, 2] undergoes one pass of bubble sort (compare each adjacent pair from left to right and swap if out of order)…
- Problem: In the array [2, 9, 4, 7, 1, 8], find the 4th smallest element using the quickselect idea (its final answer is the value that…
- Problem: In the sorted array [1, 2, 4, 7, 8, 11, 13], how many pairs (i, j) with i < j have a[j] − a[i] ≤ 2?
- Problem: Piles of bananas are [3, 6, 7, 11] and you must finish all of them within 8 hours. Each hour you eat up to k bananas from one…
- Problem: Intervals [1,4], [3,8], [6,9], [10,12], [2,5] are given. How many of them contain the point 5 (endpoints included)?