1. Matrix Gravity Drop Simulation
Given an m × n
matrix where:
'F'
represents a target'#'
represents an obstacle'-'
represents empty space
The entire connected 'F' block will drop down due to gravity until:
- It reaches the bottom row.
- At least one
'F'
touches an'#'
.
Solution Approach
- Find all
'F'
positions and determine the lowest row each column can move down to. - Compute the minimum possible drop distance among all
'F'
. - Move all
'F'
downward by that distance while preserving the structure. - Return the final matrix state.
2. Flip Number Function
Given a number x
, define flip(x)
as:
- Reverse digits while ignoring leading zeros in the result.
Examples:
flip(800) = 8
flip(210) = 12
flip(123) = 321
3. Count Valid Expressions in an Array
Given an array arr
, count the number of valid pairs (i, j)
where:
arr[i] + flip(arr[j]) = arr[j] + flip(arr[i])
Solution Approach
- Rewrite the equation:
arr[i] - flip(arr[i]) = arr[j] - flip(arr[j])
- Create a dictionary to store the count of each unique difference:
diff = arr[i] - flip(arr[i])
- Iterate again and count occurrences of
diff
to determine valid pairs. - Time Complexity:
O(n)
.
我们长期稳定承接各大科技公司如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.
