[LeetCode C++实现]1551. Minimum Operations to Make Array Equal
比较直观好理解的解法:
class Solution {
public:
int minOperations(int n) {
int res = 0;
for(int i = 1;i <= n;i++)
{
int num = 2*(i-1) + 1;
if(num > n)
res += num -n;
}
return res;
}
};
运行效率:
Runtime: 0 ms, faster than 100.00% of C++ online submissions for Minimum Operations to Make Array Equal......