Skip to the code
cf.
+10 XP

#297 Every Panel Order

easy

A dashboard lets users drag its panels into any order. QA wants to test every order. The panels have distinct numeric IDs in ids.

Write allPanelOrders(ids) that returns every order of the IDs, each as an array. The orders may be listed in any order, but each must appear exactly once.

Example 1

Input: ids = [7,8]
Output: [[7,8],[8,7]]

Either panel can come first.

Example 2

Input: ids = [5]
Output: [[5]]

One panel has one order.

Constraints

  • 0 <= ids.length <= 6
  • All IDs are distinct.
Saved in this browser

Run 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).