微软在北美的最新OA，我们一起来看看真题是什么吧。

### Task 1

You are presented with a two-dimensional grid of size N × M (N rows and M columns). Each cell in the grid is either black ('B') or white ('W'). A row or column is considered symmetric if it reads the same forwards as it does backward. For example, a row "BWBBWB" is symmetric whereas "BWB" isn’t. The same symmetry criterion applies to columns. In one move, you can change the color in a single cell to the opposite. Your task is to determine the minimum number of moves required to make every row and column in the grid symmetric.

**Write a function:**

`class Solution {`

public int solution(String[] grid);

}

that, given an array `grid`

consisting of N strings, all of length M (each string is a single row of the grid), returns the minimum number of moves required to make all rows and columns symmetric.

**Examples:**

- Given
`grid = ["BBWBB", "wwwBW", "BWWBW", "BWWWW"]`

, the function should return 3. In the beginning, the grid appears as follows:

2.` `

In 3 moves, we can change it to look like this:

### Task 2

We will call a sequence of integers a spike if they first increase (strictly) and then decrease (also strictly, including the last element of the increasing part). For example (4, 5, 7, 6, 3, 2) is a spike, but (1, 1, 5, 4, 3) and (1, 4, 3, 5) are not. Note that the increasing and decreasing parts always intersect, e.g.: for spike (3, 5, 2) sequence (3, 5) is an increasing part and sequence (5, 2) is a decreasing part, and for spike (2) sequence (2) is both an increasing and a decreasing part.

Your task is to calculate the length of the longest possible spike, which can be created from numbers in array A. Note that you are NOT supposed to find the longest spike as a sub-sequence of A, but rather choose some numbers from A and reorder them to create the longest spike.

**Write a function:**

`class Solution {`

public int solution(int[] A);

}

which, given an array A of integers of length N, returns the length of the longest spike which can be created from the numbers from A.

**Examples:**

- Given
`A = [1, 2]`

, your function should return 2, because (1, 2) is already a spike. - Given
`A = [2, 5, 3, 2, 4, 1]`

, your function should return 6, because we can create the following spike of length 6: (2, 4, 5, 3, 2, 1). - Given
`A = [2, 3, 3, 2, 2, 1]`

, your function should return 4, because we can create the following spike of length 4: (2, 3, 2, 1) and we cannot create any longer spike.

**Assumptions:**

- N is an integer within the range [1..100,000];
- each element of array A is an integer within the range [1..1,000,000,000].

### Task 3

Consider a non-empty string `S = S[0]S[1]...S[Q-1]`

consisting of Q characters. The period of this string is the smallest positive integer P such that:

`P ≤ Q / 2`

and`S[k] = S[k+P]`

for every K, where`0 ≤ K < Q - P`

.

For example, 8 is the period of "codilitycodilityco" and 7 is the period of "abracadabracadabra".

A positive integer M is the binary period of a positive integer N if M is the period of the binary representation of N. For example, 4 is the binary period of 955, because the binary representation of 955 is "11101111011" and its period is 4.

You are given an implementation of a function:

`class Solution {`

public int solution(int N);

}

This function, when given a positive integer N, returns the binary period of N. The function returns -1 if N does not have a binary period. For example, given `N = 955`

the function returns 4, as explained in the example above.

The attached code is still incorrect for some inputs. Despite the error(s), the code may produce a correct answer for the example test cases. The goal of the exercise is to find and fix the bug(s) in the implementation. You can modify at most two lines.

**Assume that:**

- N is an integer within the range [1..1,000,000,000].

In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.

我们提供OA代写服务，代面试服务，面试辅助服务等。对于OA代写我们将确保你获得满分，联系我们立即进行预约。

We provide services for writing online assessments (OA), proxy interviews, and interview assistance. For the OA writing service, we will ensure that you achieve a perfect score. Contact us now to make an appointment.