#3468

Find the Number of Copy Arrays

medium · 46.8% accepted · 108 likes · top 31%

array · math

⊣ practice⊣ open on leetcode ↗

Description

You are given an array original of length n and a 2D array bounds of length n x 2, where bounds[i] = [ui, vi].

You need to find the number of possible arrays copy of length n such that:

- (copy[i] - copy[i - 1]) == (original[i] - original[i - 1]) for 1 <= i <= n - 1.

- ui <= copy[i] <= vi for 0 <= i <= n - 1.

Return the number of such arrays.

Solution