注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
第一题
You are given two positive integers x and y, and a sequence of positive integers numbers. Your task is to change x and y through this process: Iterate through numbers from left to right, subtract each integer numbers[i] from the largest number between x and y (x in case of a tie), or skip numbers[i] if it is greater than both x and y..1point3acres
..
Return the number of integers in numbers that will be skipped based on these criteria..1point3acres
Example. .и
For x = 8, y = 12, and numbers = [5, 6, 6, 3, 1, 1, 2], the output should be solution(x, y, numbers) = 2.. 1point 3 acres
Explanation
At the beginning, x = 8 and y = 12..
Since x < y currently, processing numbers[0] = 5 results in x = 8 and y = 7.
Since x > y now, processing numbers[1] = 6 results in x = 2 and y = 7.
Since x < y now, processing numbers[2] = 6 results in x = 2 and y = 1.
numbers[3] = 3 will be skipped because it will be greater than both x = 2 and y = 1.
Since x > y now, processing numbers[4] = 1 results in x = 1 and y = 1.
Since x = y now, processing numbers[5] = 1 results in x = 0 and y = 1 (1 is subtracted from x because of the tie).
numbers[6] = 2 will be skipped because it will be greater than both x = 0 and y = 1.. Χ
So, since numbers[3] and numbers[6] will be skipped, the final answer is 2.. 1point 3 acres
第二题
Debuggers are a well-known feature of IDEs. When debugging, it is possible to set breakpoints at specific lines within the source code to let the debugger intercept code execution when it reaches this line.. 1point 3 acres
You are given codeLength, which represents the last line number of some code snippet that you are debugging, and a list of sorted unique integers breakpoints representing the line numbers that are set as breakpoints for the debugger. It is guaranteed that all breakpoints are on unique lines and 1 ≤ breakpoints[i] ≤ codeLength..--
You are also given a list of actions that the user made. Your task is to determine which line the debugger will end on after processing all of the user's actions. Initially, the debugger starts on line 1.
Here is a list of possible user actions controlling the debugger:
. Χ
"next" - jump to the next line. It is guaranteed that the debugger is not on the final line of che grid.
Your task is to compute how many 2 × 2 submatrices of the grid contain exactly blackCount black cells, for each 0 ≤ blackCount ≤ 4. As a result, you will return an array of 5 integers, where the ith element is the number of 2 × 2 submatrices with exactly i black cells.
It is guaranteed that black cell coordinates in the black array are pairwise unique, so the same cell is not colored twice..--
Example
For rows = 3, cols = 3, and black = [[0, 0], [0, 1], [1, 0]], the output should be solution(rows, cols, black) = [1, 2, 0, 1, 0]. ..
. 1point3acres
Expand to see the example video.
. .и
Note: If you are not able to see the video, use this link to access it.
Initially, result = [0, 0, 0, 0, 0].
The 2 × 2 submatrix with the upper-left corner at (0, 0) contains 3 black cells. result = [0, 0, 0, 1, 0].
The 2 × 2 submatrix with the upper-left corner at (0, 1) contains 1 black cell. result = [0, 1, 0, 1, 0].
The 2 × 2 submatrix with the upper-left corner at (1, 0) contains 1 black cell. result = [0, 2, 0, 1, 0].
The 2 × 2 submatrix with the upper-left corner at (1, 1) contains 0 black cells. result = [1, 2, 0, 1, 0].. Χ
新人求加米🙏🙏想看面经😭😭😭 |