The Find the Derangement of An Array interview question is a combinatorial counting problem. A "derangement" of an array is a permutation where no element appears in its original position. For an array of elements, you need to find the total number of such permutations. The result can be very large, so it is typically requested modulo .
Companies like IXL ask the Find the Derangement of An Array coding problem to test a candidate's ability to derive recursive relationships. It evaluates your knowledge of Combinatorics and your ability to optimize a recursive formula into an iterative Dynamic Programming interview pattern. It's a test of recognizing sub-problems within a permutation.
This problem is solved using a Recursive/Iterative Formula (Dynamic Programming).
(Array: [1, 2, 3])
The "Derangement" formula is a famous sequence in mathematics (the subfactorial). Practice deriving recurrence relations for other combinatorial problems like "Staircase" or "Parentheses Matching" to strengthen your Dynamic Programming skills.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Number of Strings Which Can Be Rearranged to Contain Substring | Medium | Solve | |
| Unique Paths | Medium | Solve | |
| Count All Valid Pickup and Delivery Options | Hard | Solve | |
| Find the Number of Possible Ways for an Event | Hard | Solve | |
| Number of Music Playlists | Hard | Solve |