Check whether the value at the original middle position of an odd-length integer array occurs exactly once, without requiring other values to be unique.
# Check Whether the Middle Value Is Unique
You are given an integer array `nums` of odd length. Return `true` if the value at its middle position appears exactly once in the entire array. Otherwise, return `false`.
The middle position is the zero-based index `nums.length / 2`, using integer division.
### Function
`bool isMiddleElementUnique(vector<int>& nums)`
### Example 1
**Input:** `nums = [9, 4, 6, 4, 9]`
**Output:** `true`
**Explanation:** The middle value is `6`, at index `2`, and it appears nowhere else. Repeated values `4` and `9` do not affect the answer.
### Example 2
**Input:** `nums = [7, 2, 5, 7, 3, 1, 7]`
**Output:** `false`
**Explanation:** The middle position is index `3`, whose value is `7`. That value also occurs at indices `0` and `6`, so it is not unique.
### Constraints
- `1 <= nums.length <= 100`
- `nums.length` is odd.
- `1 <= nums[i] <= 100`
### Clarifications
- Use the middle position in the given array, not the median after sorting.
- Other values may repeat; only the middle value's frequency matters.
- A one-element array always returns `true`.
### What a Strong Answer Covers
- Identifying the middle position from the odd length.
- Checking the middle value against every other position, including both ends.
- Distinguishing repeated middle values from repetitions of unrelated values.
Overview: Check whether the value at the original middle position of an odd-length integer array occurs exactly once, without requiring other values to be unique.
You are given an integer array nums of odd length. Return true if the value at its middle position appears exactly once in the entire array. Otherwise, return false.
The middle position is the zero-based index nums.length / 2, using integer division.
Function
bool isMiddleElementUnique(vector<int>& nums)
Example 1
Input:nums = [9, 4, 6, 4, 9]
Output:true
Explanation: The middle value is 6, at index 2, and it appears nowhere else. Repeated values 4 and 9 do not affect the answer.
Example 2
Input:nums = [7, 2, 5, 7, 3, 1, 7]
Output:false
Explanation: The middle position is index 3, whose value is 7. That value also occurs at indices 0 and 6, so it is not unique.
Constraints
1 <= nums.length <= 100
nums.length
is odd.
1 <= nums[i] <= 100
Clarifications
Use the middle position in the given array, not the median after sorting.
Other values may repeat; only the middle value's frequency matters.
A one-element array always returns
true
.
What a Strong Answer Covers Guidance
Identifying the middle position from the odd length.
Checking the middle value against every other position, including both ends.
Distinguishing repeated middle values from repetitions of unrelated values.