feat(content): function signatures + test cases
This commit is contained in:
@@ -8,6 +8,28 @@ categories:
|
||||
patterns:
|
||||
- matrix-traversal
|
||||
|
||||
function_signature: "def build_array(nums: list[int]) -> list[int]:"
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { nums: [0, 2, 1, 5, 3, 4] }
|
||||
expected: [0, 1, 2, 4, 5, 3]
|
||||
- input: { nums: [5, 0, 1, 2, 3, 4] }
|
||||
expected: [4, 5, 0, 1, 2, 3]
|
||||
hidden:
|
||||
- input: { nums: [0] }
|
||||
expected: [0]
|
||||
- input: { nums: [1, 0] }
|
||||
expected: [0, 1]
|
||||
- input: { nums: [0, 1, 2, 3, 4] }
|
||||
expected: [0, 1, 2, 3, 4]
|
||||
- input: { nums: [4, 3, 2, 1, 0] }
|
||||
expected: [0, 1, 2, 3, 4]
|
||||
- input: { nums: [2, 0, 1] }
|
||||
expected: [1, 2, 0]
|
||||
- input: { nums: [3, 0, 2, 1] }
|
||||
expected: [1, 3, 2, 0]
|
||||
|
||||
description: |
|
||||
Given a **zero-based permutation** `nums` (**0-indexed**), build an array `ans` of the **same length** where `ans[i] = nums[nums[i]]` for each `0 <= i < nums.length` and return it.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user