Skip to content

Practice Find the Number of Copy Arrays

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3468
LeetCode Problem

Find the Number of Copy Arrays

Problem Statement

Count integer arrays copy with the same length as original such that every adjacent difference copy[i] - copy[i - 1] equals original[i] - original[i - 1], and each copy[i] lies within the inclusive bounds[i] interval. Return the number of such arrays.

Source: Find the Number of Copy Arrays on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
original = [1,2,3,4], bounds = [[1,2],[2,3],[3,4],[4,5]]
Output
2

# Example 2

Input
original = [1,2,3,4], bounds = [[1,10],[2,9],[3,8],[4,7]]
Output
4

# Example 3

Input
original = [1,2,1,2], bounds = [[1,1],[2,3],[3,3],[2,3]]
Output
0

Constraints

2 <= n == original.length <= 10^5
1 <= original[i] <= 10^9
bounds.length == n
bounds[i].length == 2
1 <= bounds[i][0] <= bounds[i][1] <= 10^9

Related LeetCode Problems

Practice more problems similar to Find the Number of Copy Arrays.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.