Data Structures & AlgorithmsHardProduct Company SDE · ICPC regional
Problem: A rope of integer length 10 is cut into integer pieces (at least two pieces), and the product of the piece lengths is maximised. What is that maximum product?
- A. 27
- B. 36
- C. 32
- D. 25
Correct answer: B. 36
Use as many 3s as possible but never leave a 1: 10 = 3 + 3 + 4, product 36. Cutting 3 + 3 + 3 + 1 gives 27, five 2s give 32, and two halves give 25.
More Coding Interview Problems questions
- Problem: How many binary strings of length 6 contain neither the substring "00" nor "11"?
- Problem: The number of partitions of 12 into parts of size at most 4 (order of parts does not matter) is what value?
- Problem: The longest palindromic subsequence of "character" has what length?
- Problem: Ropes of lengths 4, 3, 2 and 6 are joined pairwise; joining two ropes costs the sum of their lengths, and the next join uses the…
- Problem: How many integers n with 1 ≤ n ≤ 100 have a binary representation that reads the same forwards and backwards?
- Problem: What is the sum of the smallest prime factors of the integers 2 through 30 (each integer contributes its smallest prime divisor)?