Every Distinct Playback Order of a Playlist With Repeated Reels

Last updated: November 29, 2026

Quick Overview

Given a list of reel ids that may contain repeats, return every distinct ordering of the list. Identical reels in swapped positions count as the same ordering.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given a list of reel ids that may contain repeats, return every distinct ordering of the list. Identical reels in swapped positions count as the same ordering.

Ordering experiments on Reels sometimes enumerate every arrangement of a short candidate list, and duplicates must not inflate the set. Meta interviewers check that you dedup structurally with counts rather than with a hash set over results.

What the Interviewer Expects
  • Recognize the duplicate problem in naive permutation
  • Branch on distinct values with remaining counts
  • Restore counts after each recursive call
  • Compute the expected output size with the multinomial formula
  • Compare with the sorted-plus-used-array approach
Key Topics to Cover
Backtracking
Permutations
Counting
Hash map
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you produce the next ordering in lexicographic order instead of all of them?
  • How would you return only orders where the same reel is never adjacent?
  • How would you find the k-th ordering directly?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input length up to 8, values may repeat.
  • Return all distinct permutations, any order.
  • An empty list has one ordering, the empty one....
High-Level Design

Count each distinct reel. Build the ordering position by position: at each position, loop over distinct reels that still have a positive count, take one, recurse, then give it back. Because each disti...


Submit Your Answer
Markdown supported