1. Encryption Using Pascal Triangle
In order to ensure maximum security, the developers at Amazon employ multiple encryption methods to keep user data protected.
In one method, numbers are encrypted using a scheme called 'Pascal Triangle'.
When an array of digits is fed to this system:
- It sums the adjacent digits.
- It then takes the rightmost digit (least significant digit) of each addition for the next step.
- The number of digits in each step is reduced by 1.
This procedure is repeated until there are only 2 digits left, and this sequence of 2 digits forms the encrypted number.
Task:
Given the initial sequence of the digits of numbers, find the encrypted number. You should report a string of digits representing the encrypted number.
Example:
- Input:
numbers = [4, 5, 6, 7]
- Output:
"04"
2. Minimum Insertions for Subsequence
Amazon CodeCraft introduces you to an engaging problem-solving challenge. You are presented with two integer lists named:
- initialList (length: mm)
- finaList (length: nn).
The finaList contains unique integers, while the initialList may contain duplicates.
Allowed Operation
You are allowed to perform the following operation any number of times (including zero):
- Insert any positive integer at any position (including the start and the end of the list) in the initialList.
Goal
Determine the minimum number of operations required to transform the initialList into a subsequence of the finaList.
Note:
A subsequence of an array is a sequence that can be derived from the array by deleting some or no elements, without changing the order of the remaining elements.
- Example:
[2, 7, 4]
is a subsequence of[4, 2, 3, 7, 2, 1, 4]
.- Example:
[2, 4, 2]
is not a subsequence of[4, 2, 3, 7, 2, 1, 4]
.
Example
- n=3n = 3
finaList=[5,1,3]\text{finaList} = [5, 1, 3] - m=5m = 5
initialList=[9,4,2,3,4]\text{initialList} = [9, 4, 2, 3, 4]
Steps to Transform:
- Operation 1:
- Insert
5
:
initialList=[5,9,4,2,3,4]\text{initialList} = [5, 9, 4, 2, 3, 4]
Current common subsequence:[5, 3]
.
- Insert
- Operation 2:
- Insert
1
:
initialList=[5,9,4,1,2,3,4]\text{initialList} = [5, 9, 4, 1, 2, 3, 4]
Current common subsequence:[5, 1, 3]
.
- Insert
Now, consider the subsequence formed from the elements at index [0, 3, 5]
of the initialList. This matches the finaList.
Result: A minimum of 2 operations is required.
Function Description
Complete the function minimuminsertions
in the editor below.
- Input:
int finaList[n]
: the elements in the finalList.int initialList[m]
: the elements in the initialList. - Output:
int
: Minimum operations required to make finaList a subsequence of the elements in the initialList.
CSOAhelp长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
CSOAhelp consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.