List the K Cheapest Pairings of Azure Compute and Storage SKUs
Last updated: November 29, 2026
Quick Overview
Given sorted monthly prices for compute SKUs and for storage SKUs, return the k compute and storage pairings with the lowest combined price, cheapest first.
Microsoft
November 29, 20260
0
0 solved
Given sorted monthly prices for compute SKUs and for storage SKUs, return the k compute and storage pairings with the lowest combined price, cheapest first.
A k-way merge with a heap, framed as an Azure pricing calculator feature. The interviewer checks that the candidate does not build all m x n pairs, and that the heap starts with one frontier entry per row.
What the Interviewer Expects
- Avoid materializing all m x n sums
- Seed the heap with (compute[i], storage[0]) for the first k rows
- After popping (i, j), push (i, j + 1)
- Prove that no pair is missed or repeated
- State O(k log k) time
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- What if the input lists are not sorted?
- Return the k-th cheapest total only, using binary search on the answer.
- Extend to three categories: compute, storage, and networking.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
computeandstorageare sorted ascending (duplicates allowed).- Output: up to k pairs
(c, s)in increasing c + s....
High-Level Design
Think of a grid where cell (i, j) holds compute[i] + storage[j]. Rows and columns are sorted, so each row is a sorted list and the problem becomes merging m sorted rows and stopping after k items. Sta...