Data Structures & AlgorithmsVery hardICPC regional · GATE CS
How many permutations of the numbers 1 to 6 have a longest increasing subsequence of length exactly 3?
- A. 181
- B. 401
- C. 61
- D. 381
Correct answer: D. 381
This is a counting problem solved by a Robinson–Schensted style argument or by enumeration: a permutation of 6 has at most 720 orders, and the LIS length is computed for each. Guessing from the Catalan numbers is a common slip.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many permutations of 1, 2, 3, 4, 5 have EXACTLY 4 inversions? An inversion is a pair of positions i < j with p[i] > p[j].
- Piles of stones [3, 5, 1, 2, 6] are in a row. Each move merges two ADJACENT piles into one, at a cost equal to their combined number of…
- In how many different ways can the product of 5 matrices A·B·C·D·E be fully parenthesised (grouping by brackets, keeping the order of…
- Two players alternately take a pile from either END of the row [4, 15, 3, 9, 2, 8]; the first player moves first and each takes the whole…
- You may partition the multiset [3, 1, 4, 1, 5, 9, 2, 6] into as many GROUPS as possible, where every group must have sum at least 7 and…
- From the numbers [7, 2, 9, 4, 1, 6, 3], choose the largest possible number of elements (each used at most once) whose total is at most 12…