7
ll numWays(ll n, ll k) {9
return 0; // can't have no stick visible or more sticks visible than the10
// total number of sticks11
if (n <= 2) return 1; // base condition13
if (dp[n][k] != -1) return dp[n][k]; // return if already calculated17
// select the tallest stick18
ans = (ans + numWays(n - 1, k - 1)) % mod;20
// select any of the n - 1 sticks that are not the tallest21
ans = (ans + ((n - 1) * numWays(n - 1, k))) % mod;23
return dp[n][k] = ans;26
int rearrangeSticks(int n, int k) {27
dp = vector<vector<ll>>(n + 1, vector<ll>(k + 1, -1));