#3576
Transform Array to All Equal Elements
expert · 1095 · lc medium +32 · 33% accepted · 94 likes · top 11%
Description
An integer array nums of size n contains only 1 and -1, and you have at most k operations.
Each operation: pick any index i (0 <= i < n - 1) and negate both nums[i] and nums[i + 1]. The same index may be reused across different operations.
Return true if all elements can be made equal in at most k operations, otherwise return false.
Code
1
2
3