Measure a Shared Contiguous Array Block
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Other
### Problem
Return the greatest length of a contiguous block occurring in both nums 1 and nums 2. A subsequence with gaps does not qualify.
```cpp
class Solution {
public:
int findLength(vector<int>& nums1, vector<int>& nums2);
};
```
### Examples
**Example 1:**
```text
nums1 = [2,4,6,8], nums2 = [1,4,6,9]
Output: 2
Explanation: [4,6] occurs contiguously in both arrays.
```
**Example 2:**
```text
nums1 = [1,2], nums2 = [3,4]
Output: 0
Explanation: They share no element.
```
### Constraints
- Each array has from 1 to 1000 entries.
- Every entry belongs to [0,100].
### Contract considerations
Require contiguity in both arrays.
```hint Read the boundary condition
What state records the shared block ending at a pair of indices?
```
### Boundary reminders
Require contiguity in both arrays.
Overview: Measure a Shared Contiguous Array Block. Return the greatest length of a contiguous block occurring in both nums 1 and nums 2.