A music app shuffles a playlist, but it only shows each song's genre ID, given in genres. Many songs share a genre, so different shuffles can look the same.
Write distinctGenreOrders(genres) that returns every distinct sequence of genre IDs that a shuffle can show. The sequences may be listed in any order, but each must appear exactly once.
Input: genres = [1,1,2] Output: [[1,1,2],[1,2,1],[2,1,1]]
There are 6 shuffles of 3 songs, but swapping the two genre-1 songs looks the same, so only 3 sequences are distinct.
Input: genres = [3,3] Output: [[3,3]]
Both songs show genre 3, so every shuffle looks the same.
1 <= genres.length <= 80 <= genres[i] <= 9Run 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 #298 Distinct Playlist Orders. 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.