Data Structures & AlgorithmsModerateCAT · TCS NQT
Problem: The product of the numbers from 1 to 10, divided by the product of the numbers from 1 to 7, is what value?
- A. 518400
- B. 6
- C. 720
- D. 5040
Correct answer: C. 720
10!/7! cancels to 8 · 9 · 10 = 720. Dividing 10! by 7 gives 518400, 3! = 6 confuses the count of factors with their product, and 10 · 9 · 8 · 7 = 5040 cancels only 6!.
More Coding Interview Problems questions
- Problem: A string is "xoxoxox". How many substrings of length 3 are equal to "xox"?
- Problem: Consider the graph on vertices 1–6 with edges 1-2, 2-3, 3-4, 4-1, 5-6. What is the size of its largest connected component?
- Problem: Starting at index 0 of the array [2, 4, 1, 6, 3], repeatedly jump forward by the value at the current index (no wraparound; the…
- Problem: How many integers in the range 1 to 100 are both a multiple of 3 and have a digit sum equal to 6?
- Problem: The string "abcdefg" is rotated right by 3 positions. What is the first character of the rotated string?
- Problem: For the set {1, 2, 3, 4, 5, 6, 7, 8}, how many 3-element subsets have a sum that is even?