- Disk Clustering
The hard disk of a computer has n sectors, where the size stored in the iᵗʰ sector is denoted by sectorCost[i], for all 1 ≤ i ≤ n. The hard disk needs to be divided into exactly clusterCount clusters. A cluster division of a hard disk into clusterCount parts looks like this:
- sectorCost[1, ..., x₁], sectorCost[x₁ + 1, ..., x₂], ..., sectorCost[xₙ₋₁ + 1, ..., n].
The cost of cluster division into a part [x, ..., y] is defined as sectorCost[x] + sectorCost[y].
Find the minimum and the maximum possible costs of cluster division. Return an array of 2 elements where the first element represents the minimum possible cost of clustering and the second element represents the maximum possible cost of clustering.
Example
Given n = 5, sectorCost = [1, 2, 3, 2, 5] and clusterCount = 3.
Minimum Cost -
If the disk is clustered as [1], [2], [3, 2, 5].
Cost of partitioning = (sectorCost[1] + sectorCost[1]) + (sectorCost[2] + sectorCost[2]) + (sectorCost[3] + sectorCost[5])
= (1 + 1) + (2 + 2) + (3 + 5) = 14. (1-based indexing)
Maximum Cost -
If the disk is clustered as [1, 2, 3], [2], [5].
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.
