Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Rearrange Sticks With K Visible

Try to solve the Number of Ways to Rearrange Sticks With K Sticks Visible problem.

Statement

You are given two integers, n and k. There are n uniquely sized sticks with lengths ranging from 11 to n. You need to arrange these sticks in a single line such that looking from the left, exactly k sticks are visible. A stick is visible from the left if there are no sticks to its left that have a greater length.

Return the total number of permutations of the sticks such that exactly k sticks are visible from the left. Since the answer can be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000

  • 1≤1 \leq k ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Rearrange Sticks With K Visible

Try to solve the Number of Ways to Rearrange Sticks With K Sticks Visible problem.

Statement

You are given two integers, n and k. There are n uniquely sized sticks with lengths ranging from 11 to n. You need to arrange these sticks in a single line such that looking from the left, exactly k sticks are visible. A stick is visible from the left if there are no sticks to its left that have a greater length.

Return the total number of permutations of the sticks such that exactly k sticks are visible from the left. Since the answer can be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000

  • 1≤1 \leq k ≤\leq n