Google Frontend Interview Questions

First question: can only select from the front or back a total of k elements, find the minimum result,
Example: K = 3, the minimum result is 3, 2, 4.

Second question: Given weights, such as (0.3, 1, 4), return the minimum result.
3, 2, 4 → 3 * 0.3 + 2 * 1 + 4 * 4
3, 2, 5 → 3 * 0.3 + 2 * 1 + 5 * 4
3, 1, 5 → 3 * 0.3 + 1 * 1 + 5 * 4
4, 1, 5 → 3 * 0.3 + 1 * 1 + 5 * 4