3576. Transform Array to All Equal Elements
You are given an integer array
numsof sizencontaining only1and-1, and an integerk.You can perform the following operation at most
ktimes:
- Choose an index
i(0 <= i < n - 1), and multiply bothnums[i]andnums[i + 1]by-1.Note that you can choose the same index
imore than once in different operations.Return
trueif it is possible to make all elements of the array equal after at mostkoperations, andfalseotherwise.
1 |
|