PROBLEMS|MOD 13|HARD

Number of Ways to Stay in the Same Place After Some Steps

Algorithms: Searching, Sorting & Big-O

Implement algorithmic solution for **Number of Ways to Stay in the Same Place After Some Steps** (Hard level). Input parameters: `data`.

// EXAMPLES

Example 1:
Input: Input: 2
Output: 12
Explanation: Result for example 1 of Number of Ways to Stay in the Same Place After Some Steps.
Example 2:
Input: Input: 5
Output: 15
Explanation: Result for example 2 of Number of Ways to Stay in the Same Place After Some Steps.

// CONSTRAINTS

  • -10^9 <= n <= 10^9
  • Time Complexity target: O(N) or O(N log N)
  • Space Complexity target: O(1) or O(N)
  • Evaluated against 600 test cases.
solution.py