public class Solution {
    public int NumWays(int steps, int arrLen) {
        int m = steps;
        int n = Math.Min(steps / 2 + 1, arrLen);
        
        int[,] dp = new int[m + 1, n];
        dp[0, 0] = 1;
        
        int mod = 1000000007;
        
        for (int i = 1; i <= m; i++) {
            for (int j = 0; j < n; j++) {
                dp[i, j] = dp[i - 1, j];
                if (j > 0) {
                    dp[i, j] = (dp[i, j] + dp[i - 1, j - 1]) % mod;
                }
                if (j < n - 1) {
                    dp[i, j] = (dp[i, j] + dp[i - 1, j + 1]) % mod;
                }
            }
        }
        
        return dp[m, 0];
    }
}
