Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: From the array [−10, −10, 5, 2], pick three numbers (distinct positions) to maximise their product. What is the maximum product?
- A. 500
- B. -100
- C. 200
- D. 1000
Correct answer: A. 500
With two large negatives, (−10)·(−10)·5 = 500 beats the three largest values 5·2·(−10) = −100. Using 2 instead of 5 gives 200, and 1000 multiplies all four numbers.
More Coding Interview Problems questions
- Problem: The edit distance (insert, delete, replace, each cost 1) between "horse" and "ros" is computed. What is it?
- Problem: What is the length of the longest common subsequence of the three strings "abc", "abd" and "ab"?
- Problem: Split the array [7, 2, 5, 10, 8] into 2 contiguous non-empty parts so that the largest part sum is as small as possible. What is…
- Problem: A 3×3 spiral is filled starting with 1 at the top-left and moving right, then down, then left, then up, spiralling inward. What…
- Problem: Count the unordered pairs (x, y) with 1 ≤ x < y ≤ 7 for which x OR y equals 7.
- Problem: In base 8, how many trailing zeros does 100! have?