**1**.**Optimizing Moves to Maintain Final Position**

Given an original set of instructions s = 'URDR', the final destination is 2 units to the right of the initial position after the character moves up, right, down, and right. If 'U' and 'D' are deleted, the destination remains the same. The answer 2 will be returned.

**Function Description**

Complete the function `getMaxDeletions`

in the editor below.

`getMaxDeletions`

has the following parameter:

string s: the original instructions that were programmed

Returns:`int`

the maximum number of instructions that can be deleted from s while maintaining the destination

**Constraints**

1 <= n <= 10^5

s contains only the characters 'U', 'D', 'L', and 'R'.

**2. Order Check**

Students in a class are asked to stand in ascending order according to their heights for the annual class photograph. Determine the number of students not currently standing in their correct positions.

**Example**

height = [1, 1, 3, 3, 4, 1]

The 3 students indicated in red at indices 2, 4, and 5 are not in the right positions. The correct positions are [1, 1, 1, 3, 3, 4]. Return 3.

**Function Description**

Complete the function `countStudents`

in the editor below.

`countStudents`

has the following parameter(s):

int height[n]: an array of heights in the order the students are standing

Returns:`int`

the number of students not standing in the correct positions.

**Constraints**

1 <= n <= 10^5

**3. Character Reprogramming**

A control device has 4 buttons that can be used to move a character around a screen in 4 directions: Up (U), Down (D), Left (L), and Right (R). The movement needs to be optimized by deleting unnecessary instructions while maintaining the same destination. Given the original set of instructions, what is the maximum number of instructions that can be deleted and still have the character reach the destination?

**Note:** The instructions that are deleted do not need to be contiguous.

**Example**

s = 'URDR'

**4. Counting Binary Substrings**

A substring is a group of contiguous characters in a string. For instance, all substrings of `abc`

are `[a, b, c, ab, bc, abc]`

.

Given a binary representation of a number, determine the total number of substrings present that match the following conditions:

- The 0's and 1's are grouped consecutively (e.g.,
`01, 10, 0011, 1100, 000111, etc.`

). - The number of 0's in the substring is equal to the number of 1's in the substring.

As an example, consider the string `001101`

. The 4 substrings matching the two conditions include `[0011, 01, 10, 01]`

. Note that `01`

appears twice, from indices 1-2 and 4-5. There are other substrings, e.g., `001`

and `011`

that match the first condition but not the second.

**Function Description**

Complete the function `counting`

in the editor below.

我们提供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.