Problem 1: Balanced Bracket Sequence
Function Description
The function isConvertibleData determines whether each string in a dataset can be transformed into a balanced bracket sequence.
Parameters:
string dataset[n]: The dataset where each string contains characters)and(.
Returns:
int[n]: An array of integers where the ith integer is1if the corresponding string can be transformed into a balanced bracket sequence and0otherwise.
Constraints:
1 ≤ n ≤ 200,0001 ≤ |dataset[i]| ≤ 100,000n × sum(|dataset[i]|) ≤ 200,000
Each string in dataset consists of characters ) and ( only.
Input Format
- The first line contains an integer,
n, the number of elements indataset. - Each of the next
nlines contains a stringdataset[i].
Sample Input:
2
)(
(())
Sample Output:
1
1
Explanation:
- For the first string
)(, the operation can rearrange the brackets to form(), which is a balanced bracket sequence. Hence, the result is1. - The second string
((()))is already balanced. Hence, the result is1.
Problem 2: Image Processing
Function Description
Implement a prototype image processing service. The function getFinalImage performs transformations on a binary image matrix.
Parameters:
int[n][n] image: The image to be processed.int rotation: The rotation parameter.int vertical_flip: The vertical flip parameter.int horizontal_flip: The horizontal flip parameter.
Returns:
int[n][n]: The final image after applying the operations.
Constraints:
1 ≤ n ≤ 20imageis a square matrix.image[i][j]is either0or1.rotationis either90,180, or270.horizontal_flip,vertical_flipare either0or1.
Operations:
- Rotate the image by
90,180, or270degrees clockwise. - Flip the image vertically if
vertical_flip = 1. - Flip the image horizontally if
horizontal_flip = 1.
Sample Input:
n = 3, rotation = 270, vertical_flip = 0, horizontal_flip = 1
image = [[1, 0, 0], [0, 1, 1], [0, 0, 1]]
Sample Output:
[[1, 1, 0],
[0, 1, 0],
[0, 0, 1]]
Explanation:
- Rotating the image by
270degrees results in:
[[0, 1, 0],
[1, 0, 0],
[1, 1, 1]]
- Vertical flip is skipped as
vertical_flip = 0. - Horizontal flip results in:
[[1, 1, 0],
[0, 1, 0],
[0, 0, 1]]
我们长期稳定承接各大科技公司如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.

