A bundler report lists the sizes of all JavaScript chunks in kilobytes. The "lightest chunks" panel shows the k smallest sizes, smallest first. Equal sizes count separately.
Write smallestK(sizes, k) that returns the k smallest values of sizes in ascending order. k is between 0 and sizes.length. Try to keep only k values in memory while scanning.
Input: sizes = [40,12,95,7,33], k = 3 Output: [7,12,33]
The three smallest sizes, smallest first.
Input: sizes = [5,1,5,1], k = 3 Output: [1,1,5]
Equal sizes count separately.
0 <= k <= sizes.length <= 10^51 <= sizes[i] <= 10^6Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #383 Smallest K Bundles. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.