種植守則
1331. Rank Transform of an Array
Given an array of integers arr, replace each element with its rank.
The rank represents how large the element is. The rank has the following rules:
Rank is an integer starting from 1.
The larger the element, the larger the rank. If two elements are equal, their rank must be the same.
Rank should be as small as possible.
Example 1:
1 | Input: arr = [40,10,20,30] |
Example 2:
1 | Input: arr = [100,100,100] |
Example 3:
1 | Input: arr = [37,12,28,9,100,56,80,5,12] |
1470. Shuffle the Array Concatenation
Given the array nums consisting of 2n elements in the form [x1,x2,…,xn,y1,y2,…,yn].
Return the array in the form [x1,y1,x2,y2,…,xn,yn].
Example 1:
1 | Input: nums = [2,5,1,3,4,7], n = 3 |
Example 2:
1 | Input: nums = [1,2,3,4,4,3,2,1], n = 4 |
Example 3:
1 | Input: nums = [1,1,2,2], n = 2 |
1640. Check Array Formation Through Concatenation
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].
Return true if it is possible to form the array arr from pieces. Otherwise, return false.
Example 1:
1 | Input: arr = [85], pieces = [[85]] |
Example 2:
1 | Input: arr = [15,88], pieces = [[88],[15]] |
Example 3:
1 | Input: arr = [49,18,16], pieces = [[16,18,49]] |
Example 4:
1 | Input: arr = [91,4,64,78], pieces = [[78],[4,64],[91]] |
Example 5:
1 | Input: arr = [1,3,5,7], pieces = [[2,4,6,8]] |