Get Min Cost
Problem Overview
- Find the minimum total cost to buy all n sequential e-books by choosing leftmost, rightmost, or both ends together up to k times.
- Inputs: cost[n], pairCost, k. Output: minimum cost as a long integer.
- Constraints: 1 ≤ n ≤ 1e5; 1 ≤ cost[i], pairCost ≤ 1e9; 1 ≤ k ≤ n; sequence updates as books are removed.
- Real-world Amazon Kindle purchase scheme; an Amazon interviews coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
