Problem 1: Valid String Check
Description:
Given a string, check if it is valid or not. A valid string must:
- Be divisible by 3 (interpreted as the numeric value of the string is divisible by 3).
- Contain the digit '7' at least twice.
Testcases:
Valid strings: 771, 777, 123777
Invalid strings: 12345, 71, 171, 70
Problem 2: Command Frequency Counter
Description:
You are given an array of commands. There are only three possible commands: cmd1
, cmd2
, and cmd3
. Your task is to return an array of size 3 that contains the frequency of each command in the input array, in the order [frequency of cmd1, frequency of cmd2, frequency of cmd3]
.
Also, any element in the form of !<index>
refers to the same command that was present at the position in the input array. Note that indexing starts from 1 (not 0).
Input:
[cmd1, cmd2, cmd3, !1, !2, cmd3, cmd1]
Output:
[3, 2, 2]
Explanation:
- At index 4 (
!1
), the command is the same as the command at index 1 (cmd1
). - At index 5 (
!2
), the command is the same as the command at index 2 (cmd2
).
Problem 3: Regional Maximum Finder
Difficulty: Medium or maybe Hard
Description:
You are given a 2D array. Your task is to find the regional maxima in the array and return a 2D array of size (X * 2) where each row contains the position [i, j] of a regional maximum.
Definition of Regional Maximum:
A cell (i, j) is considered a regional maximum if:
array[i][j] != 0
array[i][j]
is the maximum value within its region.
Definition of Region:
For a cell (i, j) with value cell
:
- The region is defined as the rectangular area
(i - cell to i + cell) * (j - cell to j + cell)
. - Exclude the corner cells from above:
(i - cell, j - cell), (i - cell, j + cell), (i + cell, j - cell), and (i + cell, j + cell)
. - If the calculated region goes out of bounds, ignore those out-of-bound cells.
Input:
[
[3, 0, 1],
[2, 0, 0],
[0, 0, 0],
]
Output:
[[0, 0], [0, 2]]
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We 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.