IBM OA Balanced Bracket Sequence -IBM-OA ghost writing -OA help

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 is 1 if the corresponding string can be transformed into a balanced bracket sequence and 0 otherwise.

Constraints:

  • 1 ≤ n ≤ 200,000
  • 1 ≤ |dataset[i]| ≤ 100,000
  • n × 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 in dataset.
  • Each of the next n lines contains a string dataset[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 is 1.
  • The second string ((())) is already balanced. Hence, the result is 1.

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 ≤ 20
  • image is a square matrix.
  • image[i][j] is either 0 or 1.
  • rotation is either 90, 180, or 270.
  • horizontal_flip, vertical_flip are either 0 or 1.

Operations:

  1. Rotate the image by 90, 180, or 270 degrees clockwise.
  2. Flip the image vertically if vertical_flip = 1.
  3. 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 270 degrees 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.

Leave a Reply

Your email address will not be published. Required fields are marked *