feat(content): function signatures + test cases

This commit is contained in:
2025-07-13 19:53:34 +01:00
parent b434eb3a49
commit a7d29b7cce
203 changed files with 4526 additions and 0 deletions

View File

@@ -9,6 +9,28 @@ categories:
patterns:
- greedy
function_signature: "def can_form_array(arr: list[int], pieces: list[list[int]]) -> bool:"
test_cases:
visible:
- input: { arr: [15, 88], pieces: [[88], [15]] }
expected: true
- input: { arr: [49, 18, 16], pieces: [[16, 18, 49]] }
expected: false
- input: { arr: [91, 4, 64, 78], pieces: [[78], [4, 64], [91]] }
expected: true
hidden:
- input: { arr: [1], pieces: [[1]] }
expected: true
- input: { arr: [1, 2, 3], pieces: [[1], [2], [3]] }
expected: true
- input: { arr: [1, 2, 3], pieces: [[2], [1], [3]] }
expected: true
- input: { arr: [1, 2, 3], pieces: [[3, 2, 1]] }
expected: false
- input: { arr: [1, 2, 3, 4], pieces: [[1, 2], [3, 4]] }
expected: true
description: |
You are given an array of **distinct** integers `arr` and an array of integer arrays `pieces`, where the integers in `pieces` are **distinct**. Your goal is to form `arr` by concatenating the arrays in `pieces` **in any order**. However, you are **not** allowed to reorder the integers in each array `pieces[i]`.