1551. Minimum Operations to Make Array Equal
Last updated
Last updated
/**
* Time complexity : O(1) since we only return the answer.
* Space complexity : O(1) since we don't allocate any additional memory here.
*/
class Solution {
public int minOperations(int n) {
return n % 2 == 0 ? n * n / 4 : (n * n - 1) / 4;
}
}/**
* Time complexity : O(1) since we only return the answer.
* Space complexity : O(1) since we don't allocate any additional memory here.
*/
class Solution {
public int minOperations(int n) {
return n * n >> 2;
}
}