Practice Number of Ways to Rearrange Sticks With K Sticks Visible
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Number of Ways to Rearrange Sticks With K Sticks Visible
Problem Statement
There are n uniquely-sized sticks whose lengths are integers from 1 to n. You want to arrange the sticks such that exactly k sticks are visible from the left. A stick is visible from the left if there are no longer sticks to the left of it. Given n and k, return the number of such arrangements. Since the answer may be large, return it modulo 10^9 + 7.
Source: Number of Ways to Rearrange Sticks With K Sticks Visible on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 3, k = 2
3
# Example 2
n = 5, k = 5
1
# Example 3
n = 20, k = 11
647427950
Constraints
Related LeetCode Problems
Practice more problems similar to Number of Ways to Rearrange Sticks With K Sticks Visible.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.