Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Stay in the Same Place After Steps

Try to solve the Number of Ways to Stay in the Same Place After Steps problem.

Statement

You have a pointer starting at index 00 in an array of length arrLen.

At each step, you can perform one of the following moves:

  • Move 11 position to the left

  • Move 11 position to the right

  • Stay in the same position

The pointer must remain within the array boundaries at all times.

Given two integers steps and arrLen, return the number of ways to end up at index 00 after exactly steps steps. Since the answer can be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq steps ≤500\leq 500

  • 1≤1 \leq arrLen ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Stay in the Same Place After Steps

Try to solve the Number of Ways to Stay in the Same Place After Steps problem.

Statement

You have a pointer starting at index 00 in an array of length arrLen.

At each step, you can perform one of the following moves:

  • Move 11 position to the left

  • Move 11 position to the right

  • Stay in the same position

The pointer must remain within the array boundaries at all times.

Given two integers steps and arrLen, return the number of ways to end up at index 00 after exactly steps steps. Since the answer can be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq steps ≤500\leq 500

  • 1≤1 \leq arrLen ≤106\leq 10^6