Minimum Operations to Make the Array Alternating
Given an array of integers nums, you are allowed to perform the following operation any number of times: choose any two indices i and j (1-indexed) such that abs(nums[i] - nums[j]) % 2 == 1 and swap nums[i] with nums[j]. The array is considered alternating if no two adjacent elements are equal. Return the minimum number of operations needed to make the array alternating.
Ada AI
I want to discuss a solution
Help me solve this
Give more examples
What's wrong with my code?
How to use 'for loop' in javascript?
javascript (node 13.12.0)