1664. Ways to Make a Fair Array
https://leetcode.com/problems/ways-to-make-a-fair-array
Description
You are given an integer array nums
. You can choose exactly one index (0-indexed) and remove the element. Notice that the index of the elements may change after the removal.
For example, if nums = [6,1,7,4,1]
:
Choosing to remove index
1
results innums = [6,7,4,1]
.Choosing to remove index
2
results innums = [6,1,4,1]
.Choosing to remove index
4
results innums = [6,1,7,4]
.
An array is fair if the sum of the odd-indexed values equals the sum of the even-indexed values.
Return the number of indices that you could choose such that after the removal, nums
is fair.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= nums.length <= 105
1 <= nums[i] <= 104
ac
Previous1663. Smallest String With A Given Numeric ValueNext1665. Minimum Initial Energy to Finish Tasks
Last updated