Tap here to switch tabs
Problem
Submissions

Problem: Form Array by Concatenating Subarrays of Another Array

med
30 min
Try to solve the Form Array by Concatenating Subarrays of Another Array problem.

Statement

You are given a 2D2 D integer array groups of length n and an integer array nums.

You need to determine if it is possible to choose n disjoint subarrays from nums such that the iextthi^{ ext{th}} chosen subarray is identical to groups[i], and the chosen subarrays appear in nums in the exact same relative order as they appear in groups.

Return true if you can choose n such disjoint subarrays, or false otherwise.

Note: Two subarrays are considered disjoint if they do not share any common elements (their index ranges in nums do not overlap).

Constraints:

  • groups.length =n= n

  • 1≤1 \leq n ≤103\leq 10^3

  • 1≤1 \leq groups[i].length, ∑\sum groups[i].length ≤103\leq 10^3

  • 1≤1 \leq nums.length ≤103\leq 10^3

  • −107≤-10^7 \leq groups[i][j], nums[k] ≤107\leq 10^7

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Form Array by Concatenating Subarrays of Another Array

med
30 min
Try to solve the Form Array by Concatenating Subarrays of Another Array problem.

Statement

You are given a 2D2 D integer array groups of length n and an integer array nums.

You need to determine if it is possible to choose n disjoint subarrays from nums such that the iextthi^{ ext{th}} chosen subarray is identical to groups[i], and the chosen subarrays appear in nums in the exact same relative order as they appear in groups.

Return true if you can choose n such disjoint subarrays, or false otherwise.

Note: Two subarrays are considered disjoint if they do not share any common elements (their index ranges in nums do not overlap).

Constraints:

  • groups.length =n= n

  • 1≤1 \leq n ≤103\leq 10^3

  • 1≤1 \leq groups[i].length, ∑\sum groups[i].length ≤103\leq 10^3

  • 1≤1 \leq nums.length ≤103\leq 10^3

  • −107≤-10^7 \leq groups[i][j], nums[k] ≤107\leq 10^7