An issue tracker stores label IDs on a ticket in labels, and the same label ID can appear more than once. A bundle is any collection of these labels, using each entry at most once.
Two bundles are the same if they contain the same IDs the same number of times, no matter which entries they came from. Write distinctBundles(labels) that returns every distinct bundle, including the empty one, each sorted ascending.
The bundles may be in any order, but each distinct bundle must appear exactly once.
Input: labels = [1,2,2] Output: [[],[1],[1,2],[1,2,2],[2],[2,2]]
Taking the first 2 or the second 2 gives the same bundle, so [2] and [1, 2] appear once each.
Input: labels = [3,3] Output: [[],[3],[3,3]]
The bundles differ only in how many 3s they hold.
0 <= labels.length <= 10-10 <= labels[i] <= 10Run 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 #293 Distinct Label 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.